Next Previous Up Top Contents Index

9.4 DUIM-Frames Module

define command-table

Definition macro

Summary

Defines a new class of command table with the specified name and properties.

Macro call

define command-table name ({supers},*) {options} end

Arguments

name
A Dylan namebnf.

supers
A Dylan namebnf.

options
A Dylan bodybnf.

Values

None.

Library

duim-frames

Module

duim-frames

Description

Defines a new class of command table with the specified name and properties. This macro is equivalent to define class, but with additional options.

The supers argument specifies a comma-separated list of command tables from which the command table you are creating should inherit. If you are not explicitly inheriting the behavior of other command tables, then supers should have the value *global-command-table*.

Each one of the options supplied describes a command for the command table. This can be either a menu item, a separator, or another command table to be included in the command table. You can supply any number of options. Each option take one of the following forms:

menu-item menu-item-descriptor;
include command-table-name;
separator;

To add a menu item or menu to a command table, include an option of the following form:

menu-item label = command-function 
  #key accelerator documentation

label
An instance of <string>. This is the label that appears in the menu.

command-function

An instance of type-union(<command>, <command-table>, <function>). The command function is the callback that is invoked to perform the intended operation for the menu item. Note that this can itself be a command table.

accelerator
An instance of false-or(<gesture>). Default value: #f. This defines a keyboard accelerator that can be used to invoke command-function in preference to the menu item itself.

documentation
An instance of false-or(<string>). Default value: #f. This specifies a documentation string for the menu item that can be used to provide online help to the user. For menu items, documentation strings are usually displayed in the status bar of your application, when the mouse pointer is placed over the menu item itself.

To add a separator to a menu, just include the following option at the point you want the separator to appear:

separator;

To include another command table in the current table, include the following option at the point you want the command table to appear:

include command-table-name;

The commands defined in command-table-name are added to the current command table at the appropriate point.

Example

The following example shows how you might create a command table for the standard Windows File menu, and how this could be integrated into the menu bar for an application. The example assumes that the appropriate command functions have already been defined for each command in the command table.

define command-table 
  *file-menu-command-table* (*global-command-table*)
  menu-item "New..."         = frame-new-file,
    accelerator:   
      make-keyboard-gesture(#"n", #"control"),
    documentation: "Creates a new document."
  menu-item "Open..."        = frame-open-file,
    accelerator:   
      make-keyboard-gesture(#"o", #"control"),
    documentation: "Opens an existing document.";
  menu-item "Close"          = frame-close-file,
    documentation: "Closes an open document.";
  separator;
  include *save-files-command-table*;
  separator;
  menu-item "Exit" 
             = make(<command>, 
                    function: exit-frame);
end command-table *file-menu-command-table*;
define command-table
  *application-command-table* (*global-command-table*)
  menu-item "File"    = *file-menu-command-table*;
  menu-item "Edit"    = *edit-menu-command-table*;
  menu-item "View"    = *view-menu-command-table*;
  menu-item "Windows" = *windows-menu-command-table*;
  menu-item "Help"    = *help-menu-command-table*;
end command-table *application-command-table*;

See also

*global-command-table*, page 822


Functional Developer Library Reference: DUIM - 3 Dec 1998

Next Previous Up Top Contents Index