WebMenuItem
From Xojo Documentation
Supported Platforms Project Types: Web Platforms: macOS, Windows, Linux |
- For desktop applications, see MenuItem.
Class (inherits from None)
New in 2011r2
An item in a WebToolbarMenu or a contextual menu used in a web page or web control.
Properties | |||||
|
Methods | ||||||
|
Constructors | |||
|
Notes
You can display a contextual menu in a web app by assigning the WebMenuItem to the WebControl.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.Append(New WebMenuItem("Item 1"))
menu.Append(New WebMenuItem("Item 2"))
Me.ContextualMenu = menu
menu.Append(New WebMenuItem("Item 1"))
menu.Append(New WebMenuItem("Item 2"))
Me.ContextualMenu = menu
Right-click on the button to show the menu.
To determine which menu was selected, use this code in the ContextualMenuAction event handler:
Select Case Item.Text
Case "Item 1"
MessageBox("Item 1 selected.")
Case "Item 2"
MessageBox("Item 2 selected.")
End Select
Case "Item 1"
MessageBox("Item 1 selected.")
Case "Item 2"
MessageBox("Item 2 selected.")
End Select
This code create a nested menu:
Var b As New WebMenuItem
Var m1 As New WebMenuItem("Parent")
Var m2 As New WebMenuItem("Child")
m1.Append(m2)
b.Append(m1)
Me.ContextualMenu = b
Var m1 As New WebMenuItem("Parent")
Var m2 As New WebMenuItem("Child")
m1.Append(m2)
b.Append(m1)
Me.ContextualMenu = b
See Also
WebToolbar, WebToolbarMenu, classes; UserGuide:Web Menus topic