Difference between revisions of "WebUIControl.ContextualMenu"

From Xojo Documentation

 
Line 3: Line 3:
 
| type = [[WebMenuItem]]
 
| type = [[WebMenuItem]]
 
| owner = [[WebUIControl]]
 
| owner = [[WebUIControl]]
 +
| ownertype=class
 +
| scope=public
 
| newinversion = 2020r1
 
| newinversion = 2020r1
 
}}
 
}}

Latest revision as of 20:16, 24 January 2022

Property (As WebMenuItem )
aWebUIControl.ContextualMenu = newWebMenuItemValue
or
WebMenuItemValue = aWebUIControl.ContextualMenu

New in 2020r1

Supported for all project types and targets.

If you assign a WebMenuItem to the control, it will be displayed when the user right-clicks the control.

Notes

On a WebPage, you can disable/remove the default contextual menu by an empty WebMenuItem class object to this property.

Sample Code

This code populates a contextual menu in the Shown event of the control.

Var menu As New WebMenuItem

menu.AddMenuItem("One")
menu.AddMenuItem("Two")
menu.AddMenuItem("Three")
Me.ContextualMenu = menu

The menu selection is then handled by the ContextualMenuSelected event when the user right-clicks on the control. For example, it can be of the form:

Select case hitItem.Value
Case "One"
MessageBox("One")
Case "Two"
MessageBox("Two")
Case "Three"
MessageBox("Three")
End Select

There are equivalent events and properties for managing contextual menus on WebPage as well.

See Also

WebMenuItem class, and Desktop RectControl.ConstructContextualMenu and RectControl.ContextualMenuAction events.