wEvent

wEvent and it's subclass hold information about an event passed to a event handler. A 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().

Subclasses:wMouseEvent wKeyEvent wSizeEvent wMoveEvent wContextMenuEvent wScrollWinEvent wTrayEvent wDragDropEvent wNavigationEvent wSetCursorEvent wStatusBarEvent wCommandEvent wScrollEvent wSpinEvent wHyperlinkEvent wListEvent wTreeEvent wIpEvent wWebViewEvent wDialogEvent
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.

Types

wWparam = WPARAM
wLparam = LPARAM

Consts

wEvent_PropagateMax = high(INT_PTR)
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 = 32772
wEvent_Destroy = 32773
wEvent_App = 33869

Procs

proc Event(window: wWindow = nil; msg: UINT = 0; wParam: wWparam = 0; lParam: wLparam = 0;
          origin: HWND = 0; userData: int = 0): wEvent {...}{.raises: [], tags: [].}
Constructor.
proc getEventObject(self: wEvent): wWindow {...}{.validate, property, inline, raises: [],
    tags: [].}
Returns the object (usually a window) associated with the event
proc getWindow(self: wEvent): wWindow {...}{.validate, property, inline, raises: [], tags: [].}
Returns the window associated with the event. The same as getEventObject().
proc getEventType(self: wEvent): UINT {...}{.validate, property, inline, raises: [], tags: [].}
Returns the type of the given event, such as wEvent_Button, aka message code.
proc getEventMessage(self: wEvent): UINT {...}{.validate, property, inline, raises: [],
                                       tags: [].}
Returns the message code of the given event. The same as getEventType().
proc getId(self: wEvent): wCommandID {...}{.validate, property, inline, raises: [], tags: [].}
Returns the ID associated with this event, aka command ID or menu ID.
proc getIntId(self: wEvent): int {...}{.validate, property, inline, raises: [], tags: [].}
Returns the ID associated with this event, aka command ID or menu ID.
proc getTimerId(self: wEvent): int {...}{.validate, property, inline, raises: [], tags: [].}
Return the timer ID. Only for wEvent_Timer event.
proc getlParam(self: wEvent): LPARAM {...}{.validate, property, inline, raises: [], tags: [].}
Returns the low-level LPARAM data of the associated windows message.
proc getwParam(self: wEvent): WPARAM {...}{.validate, property, inline, raises: [], tags: [].}
Returns the low-level WPARAM data of the associated windows message.
proc getResult(self: wEvent): LRESULT {...}{.validate, property, inline, raises: [], tags: [].}
Returns data that will be sent to system after event handler exit.
proc setResult(self: wEvent; ret: LRESULT) {...}{.validate, property, inline, raises: [],
                                        tags: [].}
Set the data that will be sent to system after event handler exit.
proc getUserData(self: wEvent): int {...}{.validate, property, inline, raises: [], tags: [].}
Return the userdata associated with a event.
proc setUserData(self: wEvent; userData: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
Set the userdata associated with a event.
proc skip(self: wEvent; skip = true) {...}{.validate, 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 a event.
proc skip=(self: wEvent; skip: bool) {...}{.validate, inline, raises: [], tags: [].}
Nim style setter for skip
proc veto(self: wEvent) {...}{.validate, inline, raises: [], tags: [].}
Prevents the change announced by this event from happening.
proc deny(self: wEvent) {...}{.validate, inline, raises: [], tags: [].}
The same as veto().
proc allow(self: wEvent) {...}{.validate, inline, raises: [], tags: [].}
This is the opposite of veto(): it explicitly allows the event to be processed.
proc isAllowed(self: wEvent): bool {...}{.validate, 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 {...}{.validate, inline, discardable, raises: [],
                                      tags: [].}
Stop the event from propagating to its parent window.
proc resumePropagation(self: wEvent; propagationLevel = wEvent_PropagateMax) {...}{.
    validate, inline, raises: [], tags: [].}
Sets the propagation level to the given value.
proc getPropagationLevel(self: wEvent): int {...}{.validate, property, inline, raises: [],
    tags: [].}
Get how many levels the event can propagate.
proc setPropagationLevel(self: wEvent; propagationLevel: int) {...}{.validate, property,
    inline, raises: [], tags: [].}
Set how many levels the event can propagate.
proc getMouseScreenPos(self: wEvent): wPoint {...}{.validate, property, inline, raises: [],
    tags: [].}
Get coordinate of the cursor. The coordinate is relative to the screen.
proc getMousePos(self: wEvent): wPoint {...}{.validate, property, raises: [], tags: [].}
Get coordinate of the cursor. The coordinate is relative to the origin of the client area.
proc getX(self: wEvent): int {...}{.validate, property, inline, raises: [], tags: [].}
Get x-coordinate of the cursor. The coordinate is relative to the origin of the client area.
proc getY(self: wEvent): int {...}{.validate, property, inline, raises: [], tags: [].}
Get y-coordinate of the cursor. The coordinate is relative to the origin of the client area.
proc lCtrlDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the left ctrl key is pressed.
proc lShiftDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the left shift key is pressed.
proc lAltDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the left alt key is pressed.
proc lWinDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the left win key is pressed.
proc rCtrlDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the right ctrl key is pressed.
proc rShiftDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the right shift key is pressed.
proc rAltDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the right alt key is pressed.
proc rWinDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the right win key is pressed.
proc ctrlDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if any ctrl key is pressed.
proc shiftDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if any shift key is pressed.
proc altDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if any alt key is pressed.
proc winDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if any win key is pressed.
proc leftDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the left mouse button is currently down.
proc rightDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the right mouse button is currently down.
proc middleDown(self: wEvent): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the middle mouse button is currently down.
proc getKeyStatus(self: wEvent): array[256, bool] {...}{.validate, property, inline,
    raises: [], tags: [].}
Return an bool array with all the pressed keys. Using const defined in wKeyCodes.nim as the index. For example:
echo event.keyStauts[wKeyCtrl]

Methods

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