wEvent

wEvent and it's subclass hold information about an event passed to an event handler. An object of wWindow can be bound to an event handler by connect proc. For example:

var button = Button(panel, label="Button")
button.connect(wEvent_Button) do (event: wEvent):
  discard

If an event is generated from a control or menu, it may also associated with a wCommandID:

var frame = Frame()
frame.connect(wEvent_Menu, wIdExit) do (event: wEvent):
  discard

For frame, button, and toolbar, you can also simply connect to a wCommandID:

var frame = Frame()
frame.connect(wIdExit) do (event: wEvent):
  discard

If the event object is not used in the handler, it can be omitted. Moreover, dot is a symbol alias for connect, so following is the simplest code:

var frame = Frame()
frame.wIdExit do ():
  discard

An event is usually generated from system. However, the user may define their own event type, create the event object, and pass to a window by wWindow.processEvent().

Notice: Event() is the only constructor for all event objects in wNim. import wNim/wEvent will import all of its subclasses automatically.

Subclasses:wMouseEvent wKeyEvent wSizeEvent wMoveEvent wContextMenuEvent wScrollWinEvent wTrayEvent wDragDropEvent wNavigationEvent wSetCursorEvent wStatusBarEvent wCommandEvent wScrollEvent wSpinEvent wHyperlinkEvent wListEvent wTreeEvent wIpEvent wWebViewEvent wDialogEvent wTextLinkEvent
Events:
wEventDescription
wEvent_SetFocusA window has gained the keyboard focus.
wEvent_KillFocusA window is about to loses the keyboard focus.
wEvent_ShowA window is about to be hidden or shown.
wEvent_ActivateA window being activated or deactivated.
wEvent_TimerA timer expires.
wEvent_PaintA window's client area must be painted.
wEvent_NcPaintA window's frame must be painted.
wEvent_HotKeyThe user presses the registered hotkey.
wEvent_CloseThe user has tried to close a window. This event can be vetoed.
wEvent_MenuHighlightThe user selects a menu item (not clicks).
wEvent_DestroyA window is being destroyed.
wEvent_DpiChangedThe effective dots per inch (dpi) for a window has changed.
wEvent_AppUsed to define private event type, usually of the form wEvent_App+x.

Consts

wEvent_PropagateMax = 9223372036854775807
wEvent_PropagateNone = 0
wEvent_SetFocus = 0x00000007
wEvent_KillFocus = 0x00000008
wEvent_Show = 0x00000018
wEvent_Activate = 0x00000006
wEvent_Timer = 0x00000113
wEvent_MenuHighlight = 0x0000011F
wEvent_Paint = 0x0000000F
wEvent_NcPaint = 0x00000085
wEvent_HotKey = 0x00000312
wEvent_DpiChanged = 0x000002E0
wEvent_Close = 32787'i32
wEvent_Destroy = 32788'i32
wEvent_App = 32961'i32

Procs

proc getEventObject(self: wEvent): wWindow {...}{.inline, raises: [], tags: [].}
Returns the object (usually a window) associated with the event
proc getWindow(self: wEvent): wWindow {...}{.inline, raises: [], tags: [].}
Returns the window associated with the event. The same as getEventObject().
proc getEventType(self: wEvent): UINT {...}{.inline, raises: [], tags: [].}
Returns the type of the given event, such as wEvent_Button, aka message code.
proc getEventMessage(self: wEvent): UINT {...}{.inline, raises: [], tags: [].}
Returns the message code of the given event. The same as getEventType().
proc getId(self: wEvent): wCommandID {...}{.inline, raises: [], tags: [].}
Returns the ID associated with this event, aka command ID or menu ID.
proc getIntId(self: wEvent): int {...}{.inline, raises: [], tags: [].}
Returns the ID associated with this event, aka command ID or menu ID.
proc getTimerId(self: wEvent): int {...}{.inline, raises: [], tags: [].}
Return the timer ID. Only for wEvent_Timer event.
proc getHotkeyId(self: wEvent): int {...}{.inline, raises: [], tags: [].}
Return the hotkey ID. Only for wEvent_HotKey event.
proc getHotkey(self: wEvent): tuple[modifiers: int, keyCode: int] {...}{.inline, raises: [],
    tags: [].}
Returns the hotkey. Valid for wEvent_HotKey, wEvent_HotkeyChanged, and wEvent_HotkeyChanging.
proc getlParam(self: wEvent): LPARAM {...}{.inline, raises: [], tags: [].}
Returns the low-level LPARAM data of the associated windows message.
proc getwParam(self: wEvent): WPARAM {...}{.inline, raises: [], tags: [].}
Returns the low-level WPARAM data of the associated windows message.
proc getResult(self: wEvent): LRESULT {...}{.inline, raises: [], tags: [].}
Returns data that will be sent to system after event handler exit.
proc setResult(self: wEvent; ret: LRESULT) {...}{.inline, raises: [], tags: [].}
Set the data that will be sent to system after event handler exit.
proc getUserData(self: wEvent): int {...}{.inline, raises: [], tags: [].}
Return the userdata associated with an event.
proc setUserData(self: wEvent; userData: int) {...}{.inline, raises: [], tags: [].}
Set the userdata associated with an event.
proc skip(self: wEvent; skip = true) {...}{.inline, raises: [], tags: [].}
This proc can be used inside an event handler to control whether further event handlers bound to this event will be called after the current one returns. It sometimes means skip the default behavior for an event.
proc skip=(self: wEvent; skip: bool) {...}{.inline, raises: [], tags: [].}
Nim style setter for skip
proc veto(self: wEvent) {...}{.inline, raises: [], tags: [].}
Prevents the change announced by this event from happening.
proc deny(self: wEvent) {...}{.inline, raises: [], tags: [].}
The same as veto().
proc allow(self: wEvent) {...}{.inline, raises: [], tags: [].}
This is the opposite of veto(): it explicitly allows the event to be processed.
proc isAllowed(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the change is allowed (veto() hasn't been called) or false otherwise (if it was).
proc stopPropagation(self: wEvent): int {...}{.inline, discardable, raises: [], tags: [].}
Stop the event from propagating to its parent window.
proc resumePropagation(self: wEvent; propagationLevel = wEvent_PropagateMax) {...}{.inline,
    raises: [], tags: [].}
Sets the propagation level to the given value.
proc getPropagationLevel(self: wEvent): int {...}{.inline, raises: [], tags: [].}
Get how many levels the event can propagate.
proc setPropagationLevel(self: wEvent; propagationLevel: int) {...}{.inline, raises: [],
    tags: [].}
Set how many levels the event can propagate.
proc lCtrlDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the left ctrl key is pressed.
proc lShiftDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the left shift key is pressed.
proc lAltDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the left alt key is pressed.
proc lWinDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the left win key is pressed.
proc rCtrlDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the right ctrl key is pressed.
proc rShiftDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the right shift key is pressed.
proc rAltDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the right alt key is pressed.
proc rWinDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the right win key is pressed.
proc ctrlDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if any ctrl key is pressed.
proc shiftDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if any shift key is pressed.
proc altDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if any alt key is pressed.
proc winDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if any win key is pressed.
proc leftDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the left mouse button is currently down.
proc rightDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the right mouse button is currently down.
proc middleDown(self: wEvent): bool {...}{.inline, raises: [], tags: [].}
Returns true if the middle mouse button is currently down.
proc getKeyStatus(self: wEvent): set[byte] {...}{.inline, raises: [], tags: [].}
Return a set of key-codes with all the pressed keys. The key-codes are defined in wKeyCodes.nim. For example:
echo wKey_Ctrl in event.keyStatus
proc getMouseScreenPos(self: wEvent): wPoint {...}{.inline, raises: [], tags: [].}
Get coordinate of the cursor. The coordinate is relative to the screen.
proc init(self: wEvent; window: wWindow = nil; msg: UINT = 0; wParam: wWparam = 0;
         lParam: wLparam = 0; origin: HWND = 0; userData: int = 0) {...}{.raises: [], tags: [].}
Initializes an event.
proc getMousePos(self: wEvent): wPoint {...}{.raises: [Exception], tags: [RootEffect].}
Get coordinate of the cursor. The coordinate is relative to the origin of the client area.
proc getX(self: wEvent): int {...}{.inline, raises: [Exception], tags: [RootEffect].}
Get x-coordinate of the cursor. The coordinate is relative to the origin of the client area.
proc getY(self: wEvent): int {...}{.inline, raises: [Exception], tags: [RootEffect].}
Get y-coordinate of the cursor. The coordinate is relative to the origin of the client area.

Methods

method getIndex(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getPosition(self: wEvent): wPoint {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getKeyCode(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getSize(self: wEvent): wSize {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setPosition(self: wEvent; x: int; y: int) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setPosition(self: wEvent; pos: wPoint) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getOrientation(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getScrollPos(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getKind(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getWheelRotation(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getSpinPos(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setSpinPos(self: wEvent; pos: int) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getSpinDelta(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setSpinDelta(self: wEvent; delta: int) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getUrl(self: wEvent): string {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getLinkId(self: wEvent): string {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getVisited(self: wEvent): bool {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getCursor(self: wEvent): wCursor {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setCursor(self: wEvent; cursor: wCursor) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getColumn(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getText(self: wEvent): string {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getItem(self: wEvent): wTreeItem {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getOldItem(self: wEvent): wTreeItem {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getInsertMark(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getPoint(self: wEvent): wPoint {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getDataObject(self: wEvent): wDataObject {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getEffect(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setEffect(self: wEvent; effect: int) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getValue(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method setValue(self: wEvent; value: int) {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getMenuItem(self: wEvent): wMenuItem {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getErrorCode(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getStart(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getEnd(self: wEvent): int {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method getMouseEvent(self: wEvent): UINT {...}{.base, raises: [], tags: [].}
Method needs to be overridden.
method shouldPropagate(self: wEventBase): bool {...}{.base, raises: [], tags: [].}
Test if this event should be propagated or not. This method can be override, for example:
method shouldPropagate(self: wEvent): bool =
  if self.eventType == wEvent_Char:
    result = true
  else:
    result = procCall shouldPropagate(wEventBase self)

Templates

template Event(window: wWindow = nil; msg: UINT = 0; wParam: wWparam = 0;
              lParam: wLparam = 0; origin: HWND = 0; userData: int = 0): wEvent
Constructor.