► |  | The Racket Graphical Interface Toolkit

1 | Windowing
2 | Widget Gallery
3 | Windowing Classes
4 | Windowing Functions
5 | Editors
6 | Snip and Style Classes
7 | Editor Classes
8 | Editor Functions
9 | WXME Decoding
10 | Preferences
11 | Dynamic Loading
12 | Startup Actions
13 | Init Libraries
14 | Platform Dependencies
| Index

▼ | 3 | Windowing Classes

3.1 | area<%>
3.2 | area-container<%>
3.3 | area-container-window<%>
3.4 | button%
3.5 | canvas<%>
3.6 | canvas%
3.7 | check-box%
3.8 | checkable-menu-item%
3.9 | choice%
3.10 | clipboard-client%
3.11 | clipboard<%>
3.12 | combo-field%
3.13 | control<%>
3.14 | column-control-event%
3.15 | control-event%
3.16 | cursor%
3.17 | dialog%
3.18 | event%
3.19 | frame%
3.20 | gauge%
3.21 | group-box-panel%
3.22 | grow-box-spacer-pane%
3.23 | horizontal-pane%
3.24 | horizontal-panel%
3.25 | key-event%
3.26 | labelled-menu-item<%>
3.27 | list-box%
3.28 | list-control<%>
3.29 | menu%
3.30 | menu-bar%
3.31 | menu-item<%>
3.32 | menu-item%
3.33 | menu-item-container<%>
3.34 | message%
3.35 | mouse-event%
3.36 | pane%
3.37 | panel%
3.38 | popup-menu%
3.39 | printer-dc%
3.40 | radio-box%
3.41 | selectable-menu-item<%>
3.42 | separator-menu-item%
3.43 | scroll-event%
3.44 | slider%
3.45 | subarea<%>
3.46 | subwindow<%>
3.47 | tab-panel%
3.48 | text-field%
3.49 | timer%
3.50 | top-level-window<%>
3.51 | vertical-pane%
3.52 | vertical-panel%
3.53 | window<%>

On this page:

command
get-shortcut
get-shortcut-prefix
set-shortcut
set-shortcut-prefix

Inherited methods:
from labelled-menu-item<%>
enable
get-help-string
get-label
get-plain-label
is-enabled?
on-demand
set-help-string
set-label
from menu-item<%>
delete
get-parent
is-deleted?
restore

top ← prev up next →

> interface

> selectable-menu-item<%> : interface?

implements: | labelled-menu-item<%>

A selectable-menu-item<%> object is a labelled-menu-item<%> that the user can select. It may also have a keyboard shortcut; the shortcut is displayed in the menu, and the default on-subwindow-char method in the menu’s frame dispatches to the menu item when the shortcut key combination is pressed.

> > method

> > (send a-selectable-menu-item command event) → void?

> event : (is-a?/c control-event%)

Invokes the menu item’s callback procedure, which is supplied when an instance of menu-item% or checkable-menu-item% is created.

> > method

> > (send a-selectable-menu-item get-shortcut)

> → (or/c char? symbol? #f)

Gets the keyboard shortcut character or virtual key for the menu item. This character or key is combined with the shortcut prefix, which is reported by get-shortcut-prefix.

If the menu item has no shortcut, #f is returned.

The shortcut part of a menu item name is not included in the label returned by get-label.

For a list of allowed key symbols, see get-key-code in key-event%, except that the following are disallowed: 'shift, 'control, 'numlock, 'scroll, 'wheel-up, 'wheel-down, 'release, and 'press.

> > method

> > (send a-selectable-menu-item get-shortcut-prefix)

> →

> (and/c (listof (or/c 'alt 'cmd 'meta 'ctl
> 'shift 'option))
> (λ (x) (implies (equal? 'unix (system-type))
> (not (and (member 'alt x)
> (member 'meta x)))))
> (λ (x) (equal? x (remove-duplicates x))))

Returns a list of symbols that indicates the keyboard prefix used for the menu item’s keyboard shortcut. The allowed symbols for the list are the following:

- 'alt — Meta (Windows and X only)

- 'cmd — Command (Mac OS only)

- 'meta — Meta (Unix only)

- 'ctl — Control

- 'shift — Shift

- 'option — Option (Mac OS only)

On Unix, at most one of 'alt and 'meta can be supplied; the only difference between 'alt and 'meta is the key combination’s display in a menu.

The default shortcut prefix is available from get-default-shortcut-prefix.

The shortcut key, as determined by get-shortcut, matches a key event using either the normally reported key code or the other-Shift/AltGr key code (as produced by get-other-shift-key-code in key-event%, etc.). When the shortcut key is a key-code symbol or an ASCII letter or digit, then the shortcut matches only the exact combination of modifier keys listed in the prefix. For character shortcuts other than ASCII letters and digits, however, then the shortcut prefix merely determines a minimum set of modifier keys, because additional modifiers may be needed to access the character; an exception is that, on Windows or Unix, the Alt/Meta key press must match the prefix exactly (i.e., included or not). In all cases, the most precise match takes precedence; see map-function in keymap% for more information on match ranking.

An empty list can be used for a shortcut prefix. However, the default on-menu-char in frame% method checks for menu shortcuts only when the key event includes either a non-Shift modifier or a Function key. Thus, an empty shortcut prefix is normally useful only if the shortcut key is a Function key.

> > method

> > (send a-selectable-menu-item set-shortcut shortcut) → void?

> shortcut : (or/c char? symbol? #f)

Sets the keyboard shortcut character for the menu item. See get-shortcut for more information.

If the shortcut character is set to #f, then menu item has no keyboard shortcut.

> > method

> > (send a-selectable-menu-item set-shortcut-prefix prefix)

> → void?

> prefix

> :

> (and/c (listof (or/c 'alt 'cmd 'meta 'ctl
> 'shift 'option))
> (λ (x) (implies (equal? 'unix (system-type))
> (not (and (member 'alt x)
> (member 'meta x)))))
> (λ (x) (equal? x (remove-duplicates x))))

Sets a list of symbols to indicates the keyboard prefix used for the menu item’s keyboard shortcut.

See get-shortcut-prefix for more information.
top ← prev up next →