Menu files
Overview: menu files
The top of the emulation window typically contains the menu bar.
The structure of this this menu system can be customized as required:
- System administrators usually perform these customizations when configuring the system: from the default menus, administrators select the appropriate menus for their implementation and make the menus available for their users as menu files.
- From this list, users simply select the appropriate menu file.
- If necessary, individual changes to the menu system can be made using the menu editor and then saved as menu files.
The structure of the settings file is described here for your reference.
However, we recommend that you always make changes using the menu editor:
- It can be very time-consuming to completely recreate such assignments.
- You require good knowledge of JavaScript and the LogWeb/Ajax API,
and you specifically use the basic menu functions from lw.Menu.
The menu system of the LogWeb/Ajax terminal emulation is implemented as a JavaScript application (as are all components). The menu file structure is described in the following:
Menu bar: lwh.menu.bar
The menu item
lwh.menu.bar
contains the main menu.
- The main menu is usually displayed at the top of the emulation window but can be hidden or displayed in the emulation using the (context) menu function
[View]/[Show Menuline].
- You define individual menu elements using the basic function
lw.Menu.makeMenu(el1, el2, ..).
- The main menu contains only references to submenus (pull-down menus).
You define these using the basic function
lw.Menu.makeLink(text, link):
lwh.menu.bar = lw.Menu.makeMenu(
lw.Menu.makeLink("Session", "lwh.menu.session" ),
lw.Menu.makeLink("Edit", "lwh.menu.edit" ),
lw.Menu.makeLink("Options", "lwh.menu.preferences" ),
lw.Menu.makeLink("View", "lwh.menu.layout" ),
lw.Menu.makeLink("Color", "lwh.menu.color" ),
lw.Menu.makeLink("Font", "lwh.menu.font" ),
lw.Menu.makeLink("Host Functions", "lwh.menu.host" ),
lw.Menu.makeSeparator(),
lw.Menu.makeLink("?", "lwh.menu.help" ),
lw.Menu.makeSeparator()
);
- For example, if you comment out the "options" link,
the corresponding anchor is no longer displayed in the menu bar, and the corresponding functions are no longer available:
...
lw.Menu.makeLink("Session", "lwh.menu.session" ),
lw.Menu.makeLink("Edit", "lwh.menu.edit" ),
//lw.Menu.makeLink("Options", "lwh.menu.preferences" ),
lw.Menu.makeLink("View", "lwh.menu.layout" ),
...
Context menu: lwh.menu.main
The menu item
lwh.menu.main
contains the context menu;
the structure is the same as that of the main menu.
- The context menu is usually displayed only when the user right-clicks the emulation window.
- Prerequisite is that the terminal-specific mouse action has the corresponding entry:
...
onclickright: '*lwk.menuMouse("lwh.menu.main")',
...
- The context menu usually displays the same entries as the menu bar:
lwh.menu.main = lwh.menu.bar;
- If required, you can define a completely different structure:
lwh.menu.main = lw.Menu.makeMenu(
lw.Menu.makeLink("Edit", "lwh.menu.edit" ),
lw.Menu.makeSeparator(),
...
lw.Menu.makeLink("Host Functions", "lwh.menu.host" ),
lw.Menu.makeSeparator()
);
Submenus: lw.Menu and lw.Menu.makeLink
The structure and the use of submenus are described in the menu bar section.
Menu actions: lw.Menu.makeAction(text, action)
Usually, menus not only contain links to submenus, but they also define actions that are performed if selected by the user.
- You define actions using the basic function
lw.Menu.makeAction(text, action):
/** 3270 host specific menu. */
lwh.menu.host = lw.Menu.makeMenu(
lw.Menu.makeAction("ENTER", "lwk.send('<ENTER>')" ),
lw.Menu.makeAction("PA1", "lwk.send('<PA1>')" ),
...
);
Meaning:
- The text specified in the first argument is displayed in the menu
(here for example: ENTER).
- If this menu item is selected, the defined JavaScript command is executed
(here: the lwk.send('<ENTER>') function is called,
which passes the ENTER key to the host system).
- If you do not want to allow specific actions, simply comment out the corresponding commands:
lwh.menu.preferences = lw.Menu.makeMenu(
...
//lw.Menu.makeSeparator(),
//lw.Menu.makeAction("Save Current Settings", "lwh.pref.save()" ),
//lw.Menu.makeAction("Restore Initial Settings", "lwh.pref.restore()" ),
lw.Menu.makeSeparator()
);
- Basically, you can define any JavaScript command as an action:
...
lw.Menu.makeAction("logics", "window.open('http://www.logics.de', 'logics')" ),
lw.Menu.makeAction("Plus 4", "alert(prompt('Please, enter a number:', 0) - 0 + 4)" ),
...
- If you want to add specific functions of the terminal emulation, you need to know the LogWeb/Ajax API.
Specific GUI elements in the menus
In addition to simple actions, specific GUI elements are specified in the menus.
You usually do not need detailed knowledge about this functions:
you can simply comment out existing links or actions or reassemble them as required.
- You define check boxes with the basic function lw.Menu.makeToggle(text, action):
lwh.menu.prefSend = lw.Menu.makeMenu(
lw.Menu.makeToggle(
"Buffer Input (type ahead)", // text
"lwh.mac.typeahead()" // bean function
),
lw.Menu.makeSeparator()
);
Meaning:
- The specified "bean" function is called unchanged before the check box is displayed:
lwh.mac.typeahead().
- The return value of the function (true or false) determines how the check box is displayed.
- If a user clicks this menu item, the bean function is called again and the current state of the check box is also passed, for example
lwh.mac.typeahead(true).
- The bean function then performs the actual action (here: input is buffered as long as a transfer to the host system is not yet completed).
- You define radio buttons using the basic function lw.Menu.makeRadio(text, action, init):
lwh.menu.prefReceive = lw.Menu.makeMenu(
lw.Menu.makeRadio(
"['No Action', 'Adjust Font to Window','Maximize Window']", // text array
"lwk.bean('lwh.pref.pFont')" // bean function
),
lw.Menu.makeSeparator()
);
Meaning:
- The text of the radio buttons is passed as a field in a string
(here: a field with the text No Action, Adjust Font to Window, Maximize Window).
This string is evaluated each time before the radio button is displayed.
- The specified bean function is called unchanged before the radio button is displayed:
lwk.bean('lwh.pref.pFont').
- Its return value (0, 1 or 2) determines which radio button is selected when displayed.
- If the user selects a radio button, the bean function is called and the number of the currently selected radio button is passed, for example lwk.bean('lwh.pref.pFont', 1).
- Only now, the bean function executes the actual action
(here: the specified value 1 is assigned to the variable lwh.pref.pFont).
- You define selection boxes using the basic function lw.Menu.makeSelect(text, action):
lwh.menu.color = lw.Menu.makeMenu(
lw.Menu.makeSelect(
"['Color Scheme: '].concat(lwh.color.names())", // text array
"lwh.color.schema()" // bean function
),
...
);
Meaning:
- The text of the drop-down list is passed as a field in a string.
The first text is placed before the drop-down list (here: Color Scheme: ).
The following text is entered in the drop-down list as options
(here, the text is dynamically identified when the lwh.color.names function is called and appended to the field).
- The specified bean function is called unchanged before the drop-down list is displayed:
lwh.color.schema().
- Its return value (0, 1 ...) determines which option is displayed as selected.
- If the user selects another option at a later time, the bean function is called again and the number of the currently selected option is passed, for example lwh.color.schema(3).
- The bean function then performs the actual action (here: the specified color scheme 3 is loaded).
- You can also define drop-down lists also using the basic function
lw.Menu.makeSelectText(text, action).
lwh.menu.menu = lw.Menu.makeMenu(
lw.Menu.makeSelectText(
"[Load Menu: '].concat(lwh.config.dir.menu)", // text array
"lwh.config.menu()" // bean function
),
...
);
Meaning:
- Same as lw.Menu.makeSelect:
The text of the drop-down list are passed as a field in a string.
The first text is placed before the drop-down list (here: Load Menu: )
The following text is entered in the selection list as options
(here, the text of the lwh.config.dir.menu array that is loaded from the server is dynamically appended to the field).
- Same as lw.Menu.makeSelect:
The specified bean function is called unchanged before the drop-down list is displayed:
lwh.config.menu().
- Same as lw.Menu.makeSelect:
Its return value (0, 1 ...) determines which option is selected when displayed.
- If the user selects another option, the bean function is called and the text (instead of the number) of the currently selected option is passed, for example lwh.config.menu('myMenu.js').
- Same as lw.Menu.makeSelect:
The bean function then performs the actual action (here: the specified menu file myMenu.js is loaded).
© Logics Software 2006 - 2009