GRIDPLUS2 - Menu | ![]() |
||||||
|
GRIDPLUS Menu |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS menu command mode. This uses a simple syntax to create a menubar and cascaded menus.
This command mode is also used to create menus for the menubutton command mode -and- the right-click pop-up menus for tablelist and tree command modes.
If the name parameter supplied to the a menu command mode identifies a toplevel window a menubar is created, otherwise a "named" (cascadable) menu is created.
GRIDPLUS Menu Layout |
The menu layout defines a list of menu options. The layout list consists of pairs of items, which can have either of the following formats:-
Where menu_name is the name of the menu, and menu_option specifies the details of a menu option. A menu may have many options. A dash ("-") may be specified as a menu_option to create a separator line.
The "~" character defines this entry as an option (which invokes a command or cascaded menu). Only one menu_option is allowed for each "~" entry. This is intended mainly for creation of cascaded menus, but may also be used to create menu_options in a menubar (See example below).
Menu Accelerator Keys |
GRIDPLUS provides a simple method to define menu accelerator keys.
The key to be used as the accelerator key should be prefixed with an underline character.
Example:
gridplus menu . { Menu_1 { {"Option _One"} {"Option _Two"} } Menu_2 { {"Option _Three"} {"Option _Four"} } }
Pressing the "Alt" key will display...
Pressing the "1" key will display...
To invoke menu "Option Two" - Press the "t" key.
GRIDPLUS Menu Item Options |
Example |
This section contains an example which illustrates the main GRIDPLUS menu command mode features.
The following example assumes that the reader is familiar with the contents of the Grid/Layout page. Information given on that page will not be duplicated here.
Note: The example assumes that the gridplus package has already been "required" and the commands imported.
Window:
With "Menu1" selected...
With "Menu2" selected...
Comments:
When using the GRIDPLUS menu command mode
each Menu consists of a menu name followed by a list of menu options.
By default, When a menu option is selected a command is invoked which as a name based on
the name of the menubar, the menu name and the option label text. The menu name and the
option label text are converted to lowercase and spaces are replaced by underscores.
For Example: When "Option Five" is select from "Menu3", the name of the
command invoked will be "menubar:menu3,option_five".
It is also possible to invoke a specific command by specifying a "~" prefixed command name.
For Example: When "Option3" is select from "Menu2", the name of the
command invoked will be "myoption3".
"Menu3" demontrates that menu option labels containg spaces must be enclosed in quotes.
Specifying an "equal" symbol ("=") instead of a menu option displays a dividing line in the
menu:-
Menu Example
gridplus menu .mymenu {
~ {"Cascade Option 1"}
~ {"Cascade Option 2" ~mycascade2}
}
gridplus menu . {
Menu1 {
{Option1}
{Option2}
}
Menu2 {
{Option3 ~myoption3 :filesave16}
{Option4 ~myoption4 :edit16}
}
Menu3 {
{"Option Five"}
{"Option Six" @mymenu}
=
{"Option Seven"}
}
~ {"Menu4" ~menu_four}
}
gridplus grid .text -padding 35 -wtitle "Menu Example" {
{"^This is a Window with a four option menubar"}
}
pack .text
Copyright © 2008 Adrian Davis.