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
Y
CursorPos
Row
Column
Item
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.