DesktopMenuItem.Popup

From Xojo Documentation

Revision as of 19:16, 23 July 2021 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
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