WebMenuItem

From Xojo Documentation

Class (inherits from Object)


New in 2011r2

An item in a WebToolbarMenu or a contextual menu used in a web page or web control.

Properties
Count fa-lock-32.png LastAddedIndex fa-lock-32.png TextColor
Enabled Position Value
Icon Tag
Methods
AddMenuItem AddMenuItemAt RemoveMenuItemAt
Enumerations
Positions
Constructors

Constructor()


Constructor(value As String)


Constructor(value As String, Tag as Variant)


Notes

You can display a contextual menu in a web app by assigning the WebMenuItem to the ContextualMenu property. When the user right+clicks on the control the contextual menu is displayed.

To create a separator, add a row using just a dash ("-").

Sample Code

To add a contextual menu to a Button, add a this code to the Shown event handler:

Var menu As New WebMenuitem
menu.AddMenuItem("Frodo")
menu.AddMenuItem("Sam")
Me.ContextualMenu = menu

Right-click on the button to show the menu.

To determine which menu was selected, use this code in the ContextualMenuSelected event handler:

Select Case Item.Value
Case "Frodo"
MessageBox("You chose Frodo.")
Case "Sam"
MessageBox("You chose Sam.")
End Select

This code create a nested menu:

Var myMenu As New WebMenuItem

Var menuItem1 As New WebMenuItem("Dark Wizards")
Var subMenuItem1 As New WebMenuItem("Sauron")
menuItem1.AddMenuItem(subMenuItem1)

myMenu.AddMenuitem(menuItem1)
Me.ContextualMenu = myMenu

See Also

WebToolbar, WebToolbarMenu, classes; UserGuide:Web Menus topic