Name
Area.ContextMenu -- set context menu for object
Function
Set this attribute to an identifier of a MOAI object derived from Menu class and the respective object will get a context menu. Whenever the user presses the right mouse button on the respective object, the context menu will be shown.

Also note that context menu events will then be delivered via the standard Menuitem.Selected mechanism and not through a special context menu event handler. Since you can use the same menu object on several widgets, you need a way to find out the widget whose context menu triggered the event. To give you this information, the event message will contain an additional item named Parent which contains the ID of the context menu's hosting widget. This allows you to re-use the same menu object as a context menu for multiple parent widgets.

Starting with RapaGUI 2.0 you can also set up a notification on the attribute. In that case, your event handler will be called immediately before RapaGUI shows the context menu. You can then return either False for no context menu or use moai.Set() on Area.ContextMenu to set the context menu that should be shown. This is very useful for customizing the context menu depending on where the right mouse button has been clicked. The position will be passed to your event handler. In case you are listening to Area.ContextMenu, your event handler will also be passed some additional information depending on the context menu's parent widget. Here is an overview of those additional message fields:

X
X coordinate of mouse click.

Y
Y coordinate of mouse click.

CursorPos
Cursor index at the position where the user clicked. This is only set for widgets of type Texteditor class.

Row
Row at the position of the mouse click or -1 if there is no row at the click position. This is only set for widgets of type Listview class.

Column
Column at the position of the mouse click or -1 if there is no column at the click position. This is only set for widgets of type Listview class.

Item
Treeview item at the position of the mouse click or -1 if there is no item at the click position. This is only set for widgets of type Treeview class.

AmigaOS users please note that MUI doesn't allow context menu objects to be shared across windows. You are not allowed to use the same menu object with widgets in different windows. It's okay to re-use a menu object for several widgets in the same window but not for widgets in another window. All other platforms don't have this limitation, only AmigaOS is affected here.

To remove a context menu completely, pass the special string "(none)" to this attribute.

See Context menus for an example.

Type
MOAI object

Applicability
ISGN


Show TOC