DesktopWindow.ContextualMenuItemSelected

From Xojo Documentation

Event


DesktopWindow.ContextualMenuItemSelected(HitItem as DesktopMenuItem) As Boolean

New in 2021r3

Supported for all project types and targets.

Fires when a contextual DesktopMenuItem HitItem was selected but the MenuItemSelected event and the MenuHandler for the DesktopMenuItem did not handle the menu selection.

Notes

This event gives you a chance to handle the menu selection by inspecting the menuitem’s Value or Tag properties to see which item was selected. Use this in conjunction with ConstructContextualMenu if you have not specified the MenuItemSelected event or the Menu Handler for the items on the contextual menu.

Example

The following code in a ConstructContextualMenu event builds a simple contextual menu. The parameter Base as DesktopMenuItem is passed in as a parameter.

base.Add(New DesktopMenuItem("Import"))
base.Add(New DesktopMenuItem("Export"))
Return True // display the contextual menu

The following Select statement in the ContextualMenuItemSelected event handler inspects the selected menu item, which is passed in as the HitItem as DesktopMenuItem parameter.

Select Case hititem.Text
Case "Import"
MessageBox("You chose Import")
Case "Export"
MessageBox("You chose export")
End Select

Return True