From Xojo Documentation

Revision as of 19:02, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Used to display a menu as a contextual menu in response to the appropriate mouse gesture. It returns True if the MouseDown event occured when the user right+clicked (Control-clicked on Macintosh), indicating that the user wishes to display a contextual menu. It works only for windows and controls that have a MouseDown event handler.



Part Type Description
result Boolean True if the user right+clicks the object (Control-clicks on Macintosh) and False if it was not.


You can display an existing menu as a contextual menu by calling the Popup method of the MenuItem class when IsContextualClick returns True. IsContextualClick then displays the MenuItem as a contextual menu. The Popup method returns the selected item as a MenuItem and fires the selected item's Action event. If the selected item is handled by a MenuHandler that returns True, then Popup will return Nil.

If the user presses the Contextual Menu key on the keyboard (either Shift+F10 or the Contextual Key on some PC keyboards), REALbasic fires a MouseDown event and sets IsContextualClick to True.

In general, it is recommended that contextual menus be implemented using the ConstructContextualMenu and ContextualMenuAction event handlers of the Window and RectControl classes. If you use that approach, there is no need to use IsContextualClick. The ConstructContextualMenu event fires when conditions are right to display a contextual menu.


The following example displays the Edit menu as a contextual menu. The code is in the MouseDown event handler of a RectControl. You can get the text of the selected item by accessing the Text property of the returned MenuItem.

If IsContextualClick Then
Dim m as MenuItem 
End if

See Also

MenuItem class.