| GRIDPLUS - 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.
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).
| 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:
Width "Menu1" selected...
Source Code:
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 Six" is select from "Menu3", the name of the
command invoked will be "menubar:menu3,option_six".
It is also possible to invoke a specific command by specifying a dot 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 a dash ("-") 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}
{Option4 .myoption4}
}
Menu3 {
{"Option Five"}
{"Option Six" @mymenu}
-
{"Option Seven"}
}
~ {"Menu4" .menu_four}
}
gridplus grid .text -pad 25 -relief groove {
{"^This is a Window with a four option menubar"}
}
gridplus layout .main -title "Menu Example" {
.text
}
pack .main
Copyright © 2004 Adrian Davis.