Blitz3D+ Command Reference

ShowPopupMenu menu,gadget[,x][,y]

Parameters

menu - popup menu from CreatePopupMenu, or any submenu

gadget - gadget the coordinates are relative to; must belong to the same window as the menu

x (optional) - x position within the gadget's client area; -1 opens at the mouse cursor (default)

y (optional) - y position within the gadget's client area; -1 opens at the mouse cursor (default)

Description

Opens a popup (context) menu and returns once the user picks an item or dismisses it.

Requires Extended language mode.

Build the menu once with CreatePopupMenu and CreateMenu, then open it wherever a right-click lands. The two classic triggers: a $201 mouse-down event with EventData()=2 (right button) on a gadget, opening at EventX(),EventY(); or a plain button opening it with the default cursor position.

Choosing an item posts the same $1001 menu-action event a menu bar produces, with the item's tag in EventData and EventSource 0 - so one handler can serve the menu bar and every context menu. Dismissing the menu posts nothing.

The native menu is built fresh on every call, so CheckMenu, EnableMenu and SetMenuText changes show immediately - no UpdateWindowMenu needed for popups. Coordinates are logical pixels relative to the gadget; both must be zero or positive unless both are -1, and a menu paired with a gadget from a different window stops with a runtime error.

See it working in the selection and context menus sample.

See also: CreatePopupMenu, CreateMenu, EventData, CheckMenu, EnableMenu.

Index