WebMenuItem

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)


New in 2011r2

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

Enumerations
Positions Styles
Methods
AddMenuItem AddSeparator RemoveMenuItemAt
AddMenuItemAt AddSeparatorAt
Properties
Count fa-lock-32.png LastAddedIndex fa-lock-32.png Tag
Enabled Position TextColor
Icon Style Value
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.

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 class; UserGuide:Web Menus topic