29.1 Overview

Menustrip class is the base class for MUI's object oriented menus. Its children are objects of Menu class, each of them describes exactly one menu.

A Menustrip object doesn't feature many options itself, but as a subclass of Family class, it simply acts as father for multiple Menu objects.

The Menustrip object is usually specified as a child of either Application class or window class with the attributes Application.Menustrip or Window.Menustrip. Additionally, it can also be used as a context menu for other MUI objects using the Area.ContextMenu attribute.

In an XML file a menu tree is defined using the <menustrip>, <menu> and <item> tags. Here is an example definition of a simple menustrip:

 
<menustrip id="mymenustrip">
    <menu title="Project">
        <item>New...</item>
        <item>Open...</item>
        <item/>
        <item>Save</item>
        <item>Save as...</item>
        <item/>
        <item>Quit</item>
    </menu>
    <menu title="Edit">
        <item shortcut="X">Cut</item>
        <item shortcut="C">Copy</item>
        <item shortcut="V">Paste</item>
    </menu>
    <menu title="?">
        <item>Settings...</item>
        <item>MUI settings...</item>
        <item/>
        <item>About...</item>
        <item>About MUI...</item>
    </menu>
</menustrip>

Note the empty <item/> declarations: These will insert a separator bar to the menu tree. Using separator bars makes your menu more readable to the end-user. After you have written the XML declaration above you can add the menustrip to one of your windows by using the Window.Menustrip attribute as follows:

 
<window menustrip="mymenustrip">
...
</window>

It is also possible to add a menustrip as a context menu to one of your window's gadgets using the Area.ContextMenu attribute. The context menu will then appear whenever the user presses the right mouse button over the gadget that has a context menu. Here is an example of how to add a menustrip as a context menu to a listview:

 
<listview contextmenu="mymenustrip">
...
</listview>

Please note that menustrips which are used as context menus must not contain more than one <menu> tree.

It is very important to note that you have to declare your menustrips in the <application> scope because menustrips are global objects and are only attached to windows or gadgets later on. That is why it is not allowed to declare menustrips inside a <window> XML scope.


Show TOC