MenuItem.Popup

From Xojo Documentation

Method

MenuItem.Popup([x as Integer, y as Integer]) As MenuItem

New in 2005r1

Supported for all project types and targets.

Displays the MenuItem as a contextual menu.

Notes

If no parameters are passed, the contextual menu appears at the location of the mouse pointer. If you pass the optional parameters, the contextual menu appears at the passed location. The coordinates are global, not just in the object that handles the MouseDown event.

Popup returns the selected item as a MenuItem. The selected item’s Action event will be fired. If the selected item is handled by a MenuHandler that returns True, then PopUp will return Nil.

Example

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.

Var popMenu As MenuItem
popMenu = EditMenu.Clone

Var selectedMenu As MenuItem
selectedMenu = popMenu.Popup