Go to the first, previous, next, last section, table of contents.


Menu Example

Here is a simple example of how to set up a menu for mouse use.

(defvar my-menu-map
  (make-sparse-keymap "Key Commands <==> Functions"))
(fset 'help-for-keys my-menu-map)

(define-key my-menu-map [bindings]
  '("List all keystroke commands" . describe-bindings))
(define-key my-menu-map [key]
  '("Describe key briefly" . describe-key-briefly))
(define-key my-menu-map [key-verbose]
  '("Describe key verbose" . describe-key))
(define-key my-menu-map [function]
  '("Describe Lisp function" . describe-function))
(define-key my-menu-map [where-is]
  '("Where is this command" . where-is))

(define-key global-map [C-S-down-mouse-1] 'help-for-keys)

The symbols used in the key sequences bound in the menu are fictitious "function keys"; they don't appear on the keyboard, but that doesn't stop you from using them in the menu. Their names were chosen to be mnemonic, because they show up in the output of where-is and apropos to identify the corresponding menu items.

However, if you want the menu to be usable from the keyboard as well, you must bind real ASCII characters as well as fictitious function keys.


Go to the first, previous, next, last section, table of contents.