Configuration Directives

Menu Directives

These directive are used to build menus in Wapache. A menu can be attached to the top of a window, with it submenus dropping down from the menu bar, or it can be used as a context menu that opens when the user right clicks on the HTML document. A menu can also be brought up by clicking on an icon in the System Tray.

Each menu has a name. To assign a menu to a window, you supply its name to one of the following directives:

A menu can contain different types of menu items. Basic menu items are used for accessing functionalities built into the web browser, such as copy, refresh, and print. URL menu items are used for navigating to an different part of the application. They can also open new windows. Script menu items call Javascript functions defined in the HTML document. DOM menu items set a property of an element in the DOM tree identifiable by an id.

Each menu item type has a "Env" version that set an environment variable before carrying out a command. They are used for implementing menu items with state–whether a particular feature is active, for instance. Enviromental menu items have a check mark next to them when the environment variable has the intended value.

Wapache uses a message broadcast system for handling commands issued through menus. When a user selects a menu item, a message is broadcast to every browser frame in every window. Whether a frame or window actually "hears" the command is control by a regular expression pattern (described as window-name in this document). When the name of the listener matches the pattern, then it hears the command and carries it out. Otherwise the command is ignored.

Five special names are available for determining which window should process a message based on context: _this refers to the window or frame from which the command originates; _all means all windows and frames; _parent refers to the document window that contains _this while _opener is the one that opened _this (in a separate window); _other means all windows and frames except for _this. Another special name, _app, does not refer to a window at all. It is used for sending commands to the application itself.

Before showing a menu to the user, Wapache checks to see if at least one window or frame can carry out the available commands. For instance, if a function that gets call by a Script menu item is not actually defined anywhere, Wapache would gray out that item.

Description: Adds a menu item for simultaneously setting an environment variable and executing a basic command
Syntax: BasicEnvMenuItem label window-name env-name env-value command-identifier
Context: menu config

The BasicEnvMenuItem directive adds a basic menu item that sets an environment variable to a particular value before running a command. It useful for implementing user-selectable features. For example, in an application that supports multiple visual themes, the name of the current theme is stored in an persistent environment variable. When the user selects a different theme from a drop-down menu, we want the browser to refresh to show the selected theme. The menu could look like this:

A check mark would appear next to the menu item when the environment variable already has the intended value. The item itself would become inactive.

<Menu theme>
  BasicEnvMenuItem "The Good" _this theme_name good IDM_REFRESH
  BasicEnvMenuItem "The Bad" _this theme_name bad IDM_REFRESH
  BasicEnvMenuItem "The Ugly" _this theme_name ugly IDM_REFRESH
</Menu>

See BasicMenuItem for more information.

Description: Adds a menu item for executing a basic command
Syntax: BasicMenuItem label window-name command-identifier
Context: menu config

The BasicMenuItem adds a menu item for activating one of the browser's built-in functions, such a copying text to the clipboard, printing the current page, and opening the Find dialog box.

For items in a drop-down menu, you can put an ampersand in front of a letter in label to make it a keyboard mnemonic.

command-identifier is either a number or one of the pre-defined IDM_* constants. See Command Identifiers for a list of available commands. Environment variable expansion does NOT happen for this argument.

Commonly Used Commands:
IDM_UNDOUndo the last action
IDM_COPYCopy the selection to the clipboard
IDM_CUTCopy the selection to the clipboard and remove it
IDM_PASTEInsert text from the clipboard
IDM_CLEARSELECTIONRemove the selection
IDM_REFRESHRefresh the current page
IDM_CLOSEClose the window
IDM_EXITExit the program
IDM_PRINTPrint the current page
Description: Adds a menu item for simultaneously setting an environment variable and modifying an element in the HTML document
Syntax: DOMEnvMenuItem label window-name env-name env-value element-id element-property property-value
Context: menu config

The DOMEnvMenuItem directive adds a basic menu item that sets an environment variable to a particular value before setting the property of a DOM element. It useful for implementing user-selectable features. For example, in an application where the user can select the CSS stylesheet, the name of the current style is stored in an persistent environment variable. When the user selects a different style from a drop-down menu, we would change the href attribute of the <link> element that links in the CSS file. The menu could look like this:

<Menu size>
  BasicEnvMenuItem "Big" _this style big css_link href "/css/{%ENV:style}.css"
  BasicEnvMenuItem "Normal" _this style normal css_link href "/css/{%ENV:style}.css"
  BasicEnvMenuItem "Small" _this style small css_link href "/css/{%ENV:style}.css"
</Menu>

Expansion of environment variables is performed on element-id, element-property, and property-value. The mod_rewrite {%ENV:env} syntax is used.

A check mark would appear next to the menu item when the environment variable already has the intended value. The item itself would become inactive.

See DOMMenuItem for more information.

Description: Adds a menu item for modifying an element in the HTML document
Syntax: DOMMenuItem label window-name element element-property property-value
Context: menu config

The DOMMenuItem directive creates a menu item that changes the property of an element in the current document. The element needs to be identifiable through an id. Internally, Wapache obtains a reference to the object through the all collection.

Only top-level properties can be set. To change the properties of a child object (e.g. object.style), use a ScriptMenuItem.

If a given value is invalid for that object property, operation fails silently.

For items in a drop-down menu, you can put an ampersand in front of a letter in label to make it a keyboard mnemonic.

Expansion of environment variables is performed on element-id, element-property, and property-value. The mod_rewrite {%ENV:env} syntax is used.

Node: The object property coresponding to the class attribute is className.
Description: Contains directives for defining a drop-down or pop-up menu
Syntax: <menu name> ... <menu>
Context: menu config

Description: Adds an item separator to the menu
Syntax: MenuSeparator
Context: menu config

Description: Adds a menu item for simultaneously setting an environment variable and invoking a Javascript function
Syntax: ScriptEnvMenuItem label window-name env-name env-value function [args ... ]
Context: menu config

The ScriptEnvMenuItem directive adds a basic menu item that sets an environment variable to a particular value before calling a Javascript function.

A check mark would appear next to the menu item when the environment variable already has the intended value. The item itself would become inactive.

See ScriptMenuItem for more information.

Description: Adds a menu item for invoking a Javascript function
Syntax: ScriptMenuItem label window-name function [args ... ]
Context: menu config

The ScriptMenuItem directive creates a menu item that would call a Javascript function when the user selects it.

Environment variable expansion is performed on the function name and all arguments.

Arguments are always passed as text strings. Wapache assumes they are encoded in the same character set as the current document when converting them to Unicode.

If the function specified is not defined in the current document, the menu item is grayed out. If Scripting is set to Off, this would always be the case.

Any returned value is ignored. If the Javascript function encounters an error, the scripting error dialog box would appear.

Description: Adds a sub-menu
Syntax: SubMenu label menu-name
Context: menu config

The SubMenu adds a sub-menu to a menu.

Warning: Do not set menu-name to the name of the menu that containers the item. Doing so would cause Wapache to go into an infinite loop and eat up the computer's memory.
Description: Adds a menu item for launching a URL
Syntax: UrlEnvMenuItem label window-name env-name env-value url [target]
Context: menu config

The UrlEnvMenuItem directive adds a basic menu item that sets an environment variable to a particular value before directing a browser window to a URL.

A check mark would appear next to the menu item when the environment variable already has the intended value. The item itself would become inactive.

See UrlMenuItem for more information

Description: Adds a menu item for launching a URL
Syntax: UrlMenuItem label window-name url [target]
Context: menu config

The UrlMenuItem directive creates a menu item for navigating to a URL.

target is optional. When omitted, the page opens in the window whose name matches window-name. When specified, it opens in the target window.

window-name vs. target: Although it might seem that the two arguments are redundant, there is one important difference between navigating to a URL via one or the other: how Wapache reacts when the window is not already open.

As discussed above in the Message Handling section, a message is boardcast to all windows when the user select a menu item. A window "hears" a message if its name matches window-name. If no match is found then nothing happens. On the other hand, when target is specified, Wapache will open a new window if there isn't one by that name.

Expansion of environment variables is performed on url and target. The variables are inserted directly into url, without URL encoding. The result could be therefore be invalid.