WebToolbarMenu

From Xojo Documentation

Class (inherits from WebToolbarItem)


New in 2011r2


A button with a popout menu in a WebToolbar. Clicking it will display a menu. The button cannot use the toggled appearance that a WebToolbarButton has.

Properties
Caption Icon Name fa-lock-32.png
Enabled Menu

Notes

See the WebControl.Shown event for an example of populating a menu. It is assigned to a WebToolbarMenu via setting the Menu property. Menu selections are handled by the WebToolbar.MenuAction event. See that event for an example.

Example

This example populate the WebToolbarMenus ChartsButton and DatesButton in the Open event of the WebToolbar:

// Create the chart menu
Var chartMenu As New WebMenuItem
chartMenu.Append(New WebMenuItem("Line"))
chartMenu.Append(New WebMenuItem("Bar"))
chartMenu.Append(New WebMenuItem("Pie"))
chartMenu.Append(New WebMenuItem("-"))
chartMenu.Append(New WebMenuItem("3D Line"))
chartMenu.Append(New WebMenuItem("3D Bar"))
chartMenu.Append(New WebMenuItem("3D Pie"))

// Assign the menu to the WebToolbarMenu button by looking it up by name
WebToolBarMenu(Me.ItemWithName("ChartsButton")).Menu = chartMenu

// Create the Dates menu
Var dateMenu As New WebMenuItem
dateMenu.Append(New WebMenuItem("Today"))
dateMenu.Append(New WebMenuItem("Tomorrow"))
dateMenu.Append(New WebMenuItem("Next Week"))
dateMenu.Append(New WebMenuItem("Next Month"))

// Assign the menu to the WebToolbarMenu button by looking it up by name
WebToolBarMenu(Me.ItemWithName("DatesButton")).Menu = dateMenu

Menu selection is handled in the MenuAction event of the toolbar. In this case, the event handles both menus. Because it handles actions from several menus, the event is passed two parameters, Item As WebToolbarMenu and Choice As WebMenuItem. In this case, the event handler is:

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

WebMenuItem, WebToolbar, WebToolbarButton, WebToolbarContainer, WebToolbarFlexibleSpace, WebToolbarSeparator, WebToolbarSpace classes.