The code below provides definitions for the entire menu hierarchy of the task list manager, using the same activate callbacks that are described and implemented in Chapter 5, "Adding Callbacks to the Application". Note that the labels, documentation strings, and keyboard accelerators for each menu item are identical to the ones used in the original implementation of the task list manager. For completeness, the definition of *file-command-table*, described in Section 6.2 on page 76, is repeated below.
define command-table *file-command-table* (*global-command-table*)
menu-item "Open" = open-file,
accelerator: make-keyboard-gesture(#"o", #"control"),
documentation: "Opens an existing file.";
menu-item "Save" = save-file,
accelerator: make-keyboard-gesture(#"s", #"control"),
documentation: "Saves the current file to disk.";
menu-item "Save As..." = save-as-file,
documentation: "Saves the current file with a new name.";
menu-item "Exit" = exit-task,
accelerator: make-keyboard-gesture(#"f4", #"alt"),
documentation: "Exits the application.";
end command-table *file-command-table*;
define command-table *edit-command-table* (*global-command-table*)
menu-item "Cut" = cut-command,
accelerator: make-keyboard-gesture(#"x", #"control"),
documentation: "Cut the selection to the clipboard.";
menu-item "Copy" = copy-command,
accelerator: make-keyboard-gesture(#"c", #"control"),
documentation: "Copy the selection to the clipboard.";
menu-item "Paste" = paste-command,
accelerator: make-keyboard-gesture(#"v", #"control"),
documentation: "Paste the selection in the clipboard at the current position.";
end command-table *edit-command-table*;
define command-table *task-command-table*
(*global-command-table*)
menu-item "Add..." = frame-add-task,
accelerator: make-keyboard-gesture(#"a", #"control", #"shift"),
documentation: "Add a new task.";
menu-item "Remove" = frame-remove-task,
accelerator: make-keyboard-gesture(#"d", #"control", #"shift"),
documentation: "Remove the selected task from the list.";
end command-table *task-command-table*;
define command-table *help-command-table* (*global-command-table*)
menu-item "About" = about-task,
accelerator: make-keyboard-gesture(#"f1"),
documentation: "Display information about the application.";
end command-table *help-command-table*;
The definitions above can be used in place of the definition of each menu and menu button in the original implementation of the task list manager. You must place the command table definitions provided above after the callback definitions themselves, to avoid forward references.