This class creates keyboard accelerators. Keyboard accelerators, or just accelerators, are key combinations that can generate commands to be processed by a callback function. The function wb_create_control() will create and apply an accelerator table to the application.
ASCII character codes, numbers, letters and non-alphabetic characters (like $ or %) are accepted. The following special keys are also accepted (between quotes):
Strings can be preceded by one or more of the modifiers CTRL, SHIFT and ALT, followed by a plus sign (+). Strings are case-insensitive.
NOTE: To create an accelerator with the Plus key, use the "PLUS" string instead of "+". Example: "Ctrl+Plus".
Keyboard accelerators can be created in two ways:
// Create menus with accelerators $menu = wb_create_control($mainwin, Menu, array( "&File", array(ID_NEW, "&New\tCtrl+N", "", PATH_RES . "menu_new.bmp", "Ctrl+N"), array(ID_OPEN, "&Open...\tCtrl+O", "", PATH_RES . "menu_open.bmp", "Ctrl+O"), array(ID_HELP, "&Save\tF1", "", PATH_RES . "menu_save.bmp", "F1"), array(IDCLOSE, "E&xit\tAlt+F4", "", PATH_RES . "menu_exit.bmp"), // Not an accelerator )); // Create accelerators using the Accel class wb_create_control($mainwin, Accel, array( array(ID_NEW, "Ctrl+N"), array(ID_OPEN, "Ctrl+O"), array(ID_HELP, "F1") )); |
In both cases, the parameter caption of wb_create_control() is an array of arrays, where each second-level array includes an identifier and a string that identifies the accelerator.
wb_create_control
Callback functions and window handlers
Control
classes