RectControl.ContextualMenuAction

From Xojo Documentation

Revision as of 16:29, 10 April 2020 by Gperlman (talk | contribs) (Add explanation to notes about when to return true or false.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Event


RectControl.ContextualMenuAction(hitItem as MenuItem) As Boolean

New in 2005r1

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. See the example of a contextual menu in the examples for the RectControl 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 hitItem <> Nil Then MessageBox(hitItem.Value)
Return True

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