wHotkeyCtrl

A hotkey control enables the user to enter a combination of keystrokes to be used as a hotkey. The returned hotkey tuple can be used directly in wWindow.registerHotKey(). The default key to clear current content is Esc.

Appearance:
Superclass:wControl
Styles:
StylesDescription
wHkLeftThe text in the control will be left-justified (default).
wHkCentreThe text in the control will be centered.
wHkCenterThe text in the control will be centered.
wHkRightThe text in the control will be right-justified.
wHkProcessTabWith this style, press TAB key to set TAB as hotkey instead of switches focus to the next control.
Events:wCommandEvent
wCommandEventDescription
wEvent_HotkeyChangingThe hotkey is about to be changed. This event can be vetoed.
wEvent_HotkeyChangedThe hotkey was changed.

Consts

wHkLeft = 0x00000000
wHkCentre = 0x00000001
wHkCenter = 0x00000001
wHkRight = 0x00000002
wHkProcessTab = 0x00004000

Procs

proc wHotkeyToString(hotkey: tuple[modifiers: int, keyCode: int]): string {...}{.
    raises: [KeyError], tags: [].}
Helper function to convert from hotkey to string. Returns "" if failed.
proc wStringToHotkey(value: string): tuple[modifiers: int, keyCode: int] {...}{.raises: [],
    tags: [].}
Helper function to convert from string to hotkey. Returns (0, 0) if failed.
proc getHotkey(self: wHotkeyCtrl): tuple[modifiers: int, keyCode: int] {...}{.inline,
    raises: [], tags: [].}
Gets the modifiers and keyCode of the current hotkey. Modifiers is a bitwise combination of wModShift, wModCtrl, wModAlt, wModWin.
proc getValue(self: wHotkeyCtrl): string {...}{.inline, raises: [], tags: [].}
Gets the text of current hotkey.
proc getClearKey(self: wHotkeyCtrl): int {...}{.inline, raises: [], tags: [].}
Gets the key code that clears current content. The default key is Esc.
proc changeHotkey(self: wHotkeyCtrl; modifiers: int; keyCode: int) {...}{.
    raises: [KeyError], tags: [].}
Sets current hotkey by given modifiers and keyCode. This functions does not generate the wEvent_HotkeyChanged event.
proc changeHotkey(self: wHotkeyCtrl; hotkey: tuple[modifiers: int, keyCode: int]) {...}{.
    inline, raises: [KeyError], tags: [].}
Sets current hotkey. This functions does not generate the wEvent_HotkeyChanged event.
proc setHotkey(self: wHotkeyCtrl; modifiers: int; keyCode: int) {...}{.
    raises: [KeyError, Exception], tags: [RootEffect].}
Sets current hotkey by given modifiers and keyCode. This function generates a wEvent_HotkeyChanged event. To avoid this you can use changeHotkey() instead.
proc setHotkey(self: wHotkeyCtrl; hotkey: tuple[modifiers: int, keyCode: int]) {...}{.inline,
    raises: [KeyError, Exception], tags: [RootEffect].}
Sets current hotkey. This function generates a wEvent_HotkeyChanged event. To avoid this you can use changeHotkey() instead.
proc changeValue(self: wHotkeyCtrl; value: string) {...}{.inline, raises: [KeyError],
    tags: [].}
Sets current hotkey by given text (case-insensitive and ignored spaces). This functions does not generate the wEvent_HotkeyChanged event.
proc setValue(self: wHotkeyCtrl; value: string) {...}{.inline,
    raises: [KeyError, Exception], tags: [RootEffect].}
Sets current hotkey by given text (case-insensitive and ignored spaces). This function generates a wEvent_HotkeyChanged event. To avoid this you can use changeValue() instead.
proc setClearKey(self: wHotkeyCtrl; clearKey: int) {...}{.inline, raises: [], tags: [].}
Sets a key to clear current content. The default key is Esc. If more keys are needed, you can do it by handling wEvent_HotkeyChanging. For example:
hotkeyCtrl.wEvent_HotkeyChanging do (event: wEvent):
  let hotkey = event.getHotkey()
  if hotkey.modifiers == 0 and hotkey.keyCode in {wKey_Esc, wKey_Delete, wKey_Back}:
    hotkeyCtrl.hotkey = (0, 0)
    event.veto
proc init(self: wHotkeyCtrl; parent: wWindow; id = wDefaultID; value: string = "";
         pos = wDefaultPoint; size = wDefaultSize; style: wStyle = wHkLeft) {...}{.raises: [
    wNilAccess, wWindowError, wCursorError, wBrushError, Exception, IndexDefect,
    wFontError, KeyError], tags: [RootEffect].}
Initializes a hotkey control.
proc HotkeyCtrl(parent: wWindow; id = wDefaultID; value: string = ""; pos = wDefaultPoint;
               size = wDefaultSize; style: wStyle = wHkLeft): wHotkeyCtrl {...}{.inline,
    discardable, raises: [wNilAccess, wWindowError, wCursorError, wBrushError,
                        Exception, IndexDefect, wFontError, KeyError],
    tags: [RootEffect].}
Constructor.

Methods

method getDefaultSize(self: wHotkeyCtrl): wSize {...}{.raises: [], tags: [].}
Returns the default size for the control.
method getBestSize(self: wHotkeyCtrl): wSize {...}{.raises: [], tags: [].}
Returns the best acceptable minimal size for the control.
method release(self: wHotkeyCtrl) {...}{.raises: [], tags: [].}
Release all the resources during destroying. Used internally.