The WIDGET_DISPLAYCONTEXTMENU procedure displays a context-sensitive menu (also known as a pop-up or shortcut menu). Context-sensitive menus appear when the user clicks the right mouse button over a widget for which a context menu is defined. Because the widget programmer must explicitly detect the right-mouse button click and call WIDGET_DISPLAYCONTEXTMENU to display the context menu, a widget can have any number of associated context menus, which can be displayed under different circumstances.
Context menus are created by placing one or more button widgets on a base widget constructed with the CONTEXT_MENU keyword set. The context menu's base widget must have as its parent a base, draw, list, property sheet, table, tree or text widget; in the case of all but draw widgets, the parent widget must be configured to generate context menu events via the CONTEXT_EVENTS keyword. Draw widgets that support context menus must have the BUTTON_EVENTS keyword set.
The widget application's event handler routine must detect the presence of a context menu event (base, list, and text widgets) or the right mouse-button event (draw and property sheet widgets) and call WIDGET_DISPLAYCONTEXTMENU to display the context menu. Events generated when the user clicks on the context menu's buttons are handled in the normal way. If the user clicks outside the context menu, it is dismissed and no event is generated.
WIDGET_DISPLAYCONTEXTMENU, Parent, X, Y, ContextBase_ID
The widget ID of the parent widget of the context menu widget.
The x location, relative to the parent widget, at which the menu should be displayed. (In most cases this will be the x location of the user's right mouse-button click, as reported in the X field of the WIDGET_CONTEXT or WIDGET_DRAW event structure.)
The y location, relative to the parent widget, at which the menu should be displayed. (In most cases this will be the y location of the user's right mouse-button click, as reported in the Y field of the WIDGET_CONTEXT or WIDGET_DRAW event structure.)
The widget ID of the context menu base widget that contains the context menu to be displayed. Use the CONTEXT_MENU keyword to WIDGET_BASE to create a context menu base.
For examples using WIDGET_DISPLAYCONTEXTMENU, see Context-Sensitive Menus.