h1(#wxacceleratortable). Wx::AcceleratorTable An accelerator table allows the application to specify a table of keyboard shortcuts for menus or other commands. On Windows, menu or button commands are supported; on GTK (and OS X?), only menu commands are supported. A window initially has no accelerator table entries, although "menus":menu.html associated with "frames":frame.html may have shortcut keys for their entries. h2. Derived from "Object":object.html h2. Example This example shows how to create an accelerator table with three shortcut key "entries":acceleratorentry.html. Each entry specifies: * A key modifier, for example Wx::ACCEL_CTRL, definining what modifier key if any has to be pressed at the same time to get the shortcut * An integer character identifier, giving the "normal key" that is pressed with the modifier. * An event id that will be caught by an event handler acc_table = Wx::AcceleratorTable[ [ Wx::MOD_CTRL, ?n, ID_NEW_WINDOW ], [ Wx::MOD_ALT, ?x, Wx::ID_EXIT ], [ Wx::MOD_CTRL, Wx::K_DELETE, Wx::ID_CUT) ] frame.accelerator_table = acc_table Note that in ruby, using the @?x@ notation is an easy way to retrieve the integer value of the character "x". To use keys with special characters that can't be typed, such as "Delete", use wxRuby's @Wx::K_XXX@ "key code":keycode.html constants. Any of wxRuby's "modifier keys":keymod.html may be used to refine an entry. For portability between OS X and GTK and Windows, it may be preferable to use the @Wx::MOD_CMD@ modifier instead of @Wx::MOD_CTRL@. This will map to "keypress + APPLE" on OS X - the normal modifier for shortcuts, but "keypress + CTRL" on GTK and Windows. Using the events from this accelerator table, the corresponding event handler declaration to catch the first of these would look like: evt_menu(ID_NEW_WINDOW) { .... } h2. Remarks An accelerator takes precedence over normal processing and can be a convenient way to program some event handling. For example, you can use an accelerator table to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning `OK' (but not in GTK+ at present). h2. See also "AcceleratorEntry":acceleratorentry.html, "Window#set_accelerator_table":window.html#Window_setacceleratortable
h2. Methods * "AcceleratorTable.[]":#AcceleratorTable_new * "AcceleratorTable.new":#AcceleratorTable_new * "AcceleratorTable#isok":#AcceleratorTable_isok
h3(#AcceleratorTable_new). AcceleratorTable.new *AcceleratorTable.new*(%(arg-type)"AcceleratorEntry":acceleratorentry.html% *entries) *AcceleratorTable*[*(%(arg-type)"AcceleratorEntry":acceleratorentry.html% *entries] Creates a new accelerator table from the list of entries. The entries may be passed in as "AcceleratorEntry":acceleratorentry.html% objects, or for convenience, may be specified as three-element arrays, reprsenting the modifiers, the key, and the event id in turn. h4. Parameters * _entries_ The array of entries. h3(#AcceleratorTable_isok). AcceleratorTable#is_ok Boolean *is_ok*() Returns true if the accelerator table is valid.