WebMenuItem

From Xojo Documentation

Revision as of 19:19, 2 August 2019 by Gperlman (talk | contribs)


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
Count fa-lock-32.png MenuID fa-lock-32.png Text
Enabled Tag
Methods
Append Clone Insert
Child FindItem Remove
Constructors

Constructor()


Constructor(Text as String)


Constructor(Text as String, Tag as Variant)


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

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"
MsgBox("Item 1 selected.")
Case "Item 2"
MsgBox("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

See Also

WebToolbar, WebToolbarMenu, classes; UserGuide:Web Menus topic