Window.ContextualMenuAction

From Xojo Documentation

Event


Window.ContextualMenuAction(HitItem as MenuItem) As Boolean

Supported for all project types and targets.

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

Notes

This event gives you a chance to handle the menu selection by inspecting the menuitem’s Text or Tag properties to see which item was selected. Use this in conjunction with ConstructContextualMenu if you have not specified the Action 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 MenuItem is passed in as a parameter.

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

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

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

Return True