WebToolbar.MenuAction

From Xojo Documentation

Event


WebToolbar.MenuAction(Item as WebToolbarMenu,Choice as WebMenuItem)

New in 2011r2

Supported for all project types and targets.

The passed Item on the Choice WebToolbarMenu was was clicked.


Example

In this example, the Menu is named "Menu1". It is populated in the Shown event with the following code. Since there is only one menu on the toolbar, it is not necessary to use the Choice parameter.

Var tbmenu As WebToolbarMenu = WebToolbarMenu(Me.ItemWithName("SetStatusButton"))
Var menu As New WebMenuItem

menu.Append(New WebMenuItem("Active"))
menu.Append(New WebMenuItem("Pending"))
menu.Append(New WebMenuItem("Disabled"))

tbmenu.Menu = menu


The MenuAction event determines which item was selected. The parameter Choice as WebMenuItem is passed in as a parameter. It uses the following code.

Select Case choice.Text
Case "Active"
MessageBox("Change status to Active.")
Case "Pending"
MessageBox("Change status to Pending.")
Case "Disabled"
MessageBox("Change status to Disabled.")
End Select


If there is more than one menu on the toolbar, you need to handle the Item parameter as well. The example Toolbar project in the Examples folder uses two toolbar menu. They are named ChartsButton and DatesButton. The following example tests the value of Item and reports the value of the selected item on that menu.

Select Case item.Name
Case "ChartsButton"
LastAction.Text = "You selected " + choice.Text + " from the Charts menu."

Case "DatesButton"
LastAction.Text = "You selected " + choice.Text + " from the Dates menu."
End Select


See Also

WebToolbarMenu