DesktopUIControl.ContextualMenuItemSelected

From Xojo Documentation

Event


DesktopUIControl.ContextualMenuItemSelected(selectedItem as DesktopMenuItem) As Boolean

New in 2021r3

Supported for all project types and targets.

Fires when a contextual menuitem selectedItem 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 Text 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. See the example of a contextual menu in the examples for the DesktopUIControl class.

Return True if this event has handled the item the user chose from the contextual menu. Returning False will cause the control's parent to execute its ContextualMenuAction event. This can be handy if you have the same contextual menu for several controls who share the same Parent (several on the same window for example). By returning False you can handle them all in a single event.

Sample Code

This simple event handler displays the value of the selected menu item.

If selectedItem <> Nil Then MessageBox(selectedItem.Value)
Return True

A more fine-grained event handler would compare the value of selectedItem to all the expected values and take different actions depending on its value.