30.1 Overview

Menu class can be used to create a single pull-down menu which should then be filled with items derived from Menuitem class class. Menus are usually embedded inside a top-level <menubar> object. See Menubar class for details. Alternatively, they can also be embedded as submenus of other menu objects.

It is also possible to add a menu object as a context menu to one of your window's widgets using the Area.ContextMenu attribute. The context menu will then appear whenever the user presses the right mouse button over the widget that hosts the context menu. Here is an example of how to add a menu object as a context menu to a text editor widget:

 
<menu title="Context menu" id="ctxtmenu">
   <item>Cut</item>
   <item>Copy</item>
   <item>Paste</item>
</menu>

<window>
...
   <texteditor contextmenu="ctxtmenu"/>
...
</window>

Note that when using Menu class to create context menus, the Menu.Title attribute is only used on AmigaOS and compatibles. Context menus on Windows, Linux, and macOS don't show a title.


Show TOC