An accelerator table allows the application to specify a table of keyboard shortcuts for menu or button commands.The accelerator key can be either a virtual-key code or a character code. Example:
var accel = AcceleratorTable() accel.add(wAccelCtrl, wKey_S, wIdSave) accel.add(wAccelNormal, wKey_F1, wIdHelp) accel.add('o', wIdOpen) frame.acceleratorTable = accel
There is also a wFrame.shortcut() function can quickly bind a keyboard shortcut to an event handler.
Seealso: | wFrame |
---|
Types
wAcceleratorEntry {...}{.pure.} = object flag: int keyCode: int id: wCommandID isChar: bool
- wAcceleratorEntry is an object used to create an accelerator table.
Consts
wAccelNormal = 0
wAccelAlt = 0x00000010
wAccelCtrl = 0x00000008
wAccelShift = 0x00000004
Procs
proc AcceleratorEntry(flag: int; keyCode: int; id: wCommandID): wAcceleratorEntry {...}{. inline, raises: [], tags: [].}
- Constructor for virtual-key code accelerator object.
proc AcceleratorEntry(ch: char; id: wCommandID): wAcceleratorEntry {...}{.inline, raises: [], tags: [].}
- Constructor for character code accelerator object.
proc set(self: var wAcceleratorEntry; flag: int; keyCode: int; id: wCommandID) {...}{.inline, raises: [], tags: [].}
- Sets the virtual-key code accelerator. This proc exists for backward compatibility.
proc set(self: var wAcceleratorEntry; ch: char; id: wCommandID) {...}{.inline, raises: [], tags: [].}
- Sets the character code accelerator. This proc exists for backward compatibility.
proc add(self: wAcceleratorTable; entry: wAcceleratorEntry) {...}{.inline, raises: [], tags: [].}
- Adds an accelerator object to the table.
proc add(self: wAcceleratorTable; entries: openArray[wAcceleratorEntry]) {...}{.inline, raises: [], tags: [].}
- Adds multiple accelerator objects to the table.
proc add(self: wAcceleratorTable; flag: int; keyCode: int; id: wCommandID) {...}{.inline, raises: [], tags: [].}
- Adds a virtual-key code accelerator object to the table.
proc add(self: wAcceleratorTable; ch: char; id: wCommandID) {...}{.inline, raises: [], tags: [].}
- Adds a character code accelerator object to the table.
proc del(self: wAcceleratorTable; index: Natural) {...}{.inline, raises: [], tags: [].}
- Deletes the object in the table by index.
proc clear(self: wAcceleratorTable) {...}{.inline, raises: [], tags: [].}
- Clear the talbe.
proc init(self: wAcceleratorTable) {...}{.inline, raises: [], tags: [].}
- Initializes an empty accelerator table.
proc AcceleratorTable(): wAcceleratorTable {...}{.inline, discardable, raises: [], tags: [].}
- Constructor.
proc init(self: wAcceleratorTable; entries: openArray[wAcceleratorEntry]) {...}{. raises: [], tags: [].}
- Initializes a accelerator table from an openarray of wAcceleratorEntry.
proc AcceleratorTable(entries: openArray[wAcceleratorEntry]): wAcceleratorTable {...}{. inline, discardable, raises: [], tags: [].}
- Constructor.
proc init(self: wAcceleratorTable; window: wWindow) {...}{.inline, raises: [], tags: [RootEffect].}
- Initializes an accelerator table, and attach it to window.
proc AcceleratorTable(window: wWindow): wAcceleratorTable {...}{.inline, discardable, raises: [], tags: [RootEffect].}
- Constructor.
proc init(self: wAcceleratorTable; window: wWindow; entries: openArray[wAcceleratorEntry]) {...}{.inline, raises: [], tags: [RootEffect].}
- Initializes an accelerator table from an openarray of wAcceleratorEntry, and attach it to window.
proc AcceleratorTable(window: wWindow; entries: openArray[wAcceleratorEntry]): wAcceleratorTable {...}{. inline, discardable, raises: [], tags: [RootEffect].}
- Constructor.
Iterators
iterator items(self: wAcceleratorTable): wAcceleratorEntry {...}{.inline, raises: [], tags: [].}
- Iterate each item in this table.
Converters
converter tupleTowAcceleratorEntry1[T: enum | wCommandID](x: (int, int, T)): wAcceleratorEntry {...}{. inline.}
- Convert tuple to virtual-key code accelerator object.
converter tupleTowAcceleratorEntry2[T: enum | wCommandID](x: (char, T)): wAcceleratorEntry {...}{. inline.}
- Convert tuple to character code accelerator object.