IsContextualClick Function

Used to display the 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 the contextual menu for the object.

Syntax
result = IsContextualClick( )

Return Value
Result | Boolean | True if the user right+clicks the object (Control-clicks on Macintosh) and False if it was not.

# Notes

It works only for windows and controls that have a MouseDown event handler.

This function is used to determine if the user wishes to view any available contextual menus for the object they are clicking on. For more information on implementing contextual menus, see the ContextualMenu Control.

You can also 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.

Contextual menus can also 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.

# Examples

This example in a MouseDown event handler checks to see if the user has right+clicked, then displays a contextual menu.

If IsContextualClick Then
ContextualMenu1.Open //display the contextual menu
End If

# See Also

ContextualMenu control; MenuItem class.