DesktopMenuItem.Popup

From Xojo Documentation

Method

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

New in 2021r3

Supported for all project types and targets.

Displays the DesktopMenuItem 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 DesktopMenuItem. 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 DesktopUIControl. You can get the text of the selected item by accessing the Text property of the returned DesktopMenuItem.

Var popMenu As DesktopMenuItem
popMenu = EditMenu.Clone

Var selectedMenu As DesktopMenuItem
selectedMenu = popMenu.Popup