11.2 Defining Commands the Easy Way
Through the appropriate use of the options to define-editor-command (see define-command for details), you can provide the command via any number of the previously mentioned interaction styles. For example, you could install the command in the editor application's menu, as well as specifying a single keystroke command accelerator character for it.
The following example defines a command whose command name iscom-save-file
. The com-save-file
command will appear in the application's command menu asSave File
. (The command-menu name is derived from the command name in the same way as the command-line name.) The single keystrokeCONTROL-s
is also defined to invoke the command.
(define-editor-command (com-save-file :menu t :keystroke #\c-\s) () ...)Here, a command line name of
Save File
is associated with the com-save-file
command. The user can then typeSave File
to the application's interaction pane to invoke the command.(define-editor-command (com-save-file :name "Save File") () ...)Since the command processor works by establishing an input context of presentation type command and executing the resulting input, any displayed presentation can invoke a command, so long as there is a translator defined that translates from the presentation type of the presentation to the presentation type command. In this way, you can associate a command with a pointer gesture when it is applied to a displayed presentation. (See Chapter 8, "Presentation Translators in CLIM," for details.)
define-presentation-to-command-translator [Macro]
&key
(:gesture ':select) :tester :documentation :pointer-documentation (:menu t) :priority (:echo t)) arglist&body
body
Generated with Harlequin WebMaker