wxMouseEvent(3)
๐ NAME ๐
wxMouseEvent(3) โ Erlang Module Definition, and it's giving mouse lore ๐
wxMouseEvent is the event class that contains all the info about the events generated by the mouse: it holds the mouse buttons press and release events, and also the mouse move events. That's the whole assignment, bestie, and it ate. โจ
๐ฆ DESCRIPTION ๐ฆ
Okay so first thing, the button names, because you need these memorized:
Every single mouse event that involves buttons uses wxMOUSE_BTN_LEFT for the left mouse button, wxMOUSE_BTN_MIDDLE for the middle one, and wxMOUSE_BTN_RIGHT for the right one. Periodt. ๐
And if your system supports more buttons, then the wxMOUSE_BTN_AUX1 and wxMOUSE_BTN_AUX2 events can also be generated. ๐
โ ๏ธ But listen โ not all mice even have a middle button, so if you want your app to be portable, please don't go relying on the events from it. Lowkey setting yourself up. The one exception vibes: the right button click can be emulated using the left mouse button with the control key, under Mac platforms that have a single button mouse. Iykyk. ๐
Now, for the wxEVT_ENTER_WINDOW and wxEVT_LEAVE_WINDOW events โ the way this works is: the mouse counts as being inside the window if it's in the window client area and not inside one of its children. In other words, the parent window receives a wxEVT_LEAVE_WINDOW event not only when the mouse leaves the window entirely, but also when it enters one of its children. Not me getting emotionally attached to the parent window's abandonment issues ๐ญ
The position that comes with a mouse event is expressed in the window coordinates of the window which generated the event. If you want it as screen coordinates, you can use wxWindow:clientToScreen/3 to convert it โ and then possibly call wxWindow:screenToClient/2 next to convert it to the window coordinates of another window. โจ Cute little round trip, honestly.
๐ Note: observe the difference between methods likeleftDown/1and the inheritedleftIsDown/1. Here's the tea: -leftDown/1returnstruewhen the event corresponds to the left mouse button click -leftIsDown/1returnstrueif the left mouse button is currently being pressed So for example, when the user is dragging the mouse, you can useleftIsDown/1to test whether the left mouse button is (still) depressed. ๐ Also, by convention, ifleftDown/1returnstrue, thenleftIsDown/1will also returntruein wxWidgets, whatever the underlying GUI behaviour is (which is platform-dependent, obviously). And the same applies, of course, to the other mouse buttons as well. No crumbs left. ๐
See: wxKeyEvent
This class is derived, and can use functions, from:
wxEvent
wxWidgets docs: wxMouseEvent
๐ซถ Events ๐ซถ
Use wxEvtHandler:connect/3 with wxMouseEventType to subscribe to events of this type. Go off. ๐ฅ
๐ธ DATA TYPES ๐ธ
wxMouse() :: #wxMouse{}.
wxMouseEvent() :: wx:wx_object().
wxMouseEventType() ::
left_down | left_up | middle_down | middle_up | right_down |
right_up | motion | enter_window | leave_window |
left_dclick | middle_dclick | right_dclick | mousewheel |
aux1_down | aux1_up | aux1_dclick | aux2_down | aux2_up |
aux2_dclick.
Look at that whole lineup, iconic. ๐
...and there's more, bestie, hold on โ part 2 is coming ๐
๐ FUNCTIONS ๐
okay bestie, this is the main character section ๐ every single one of these takes This (aka your wxMouseEvent()) and spills a lil truth about what the mouse just did. no skips, no gatekeeping, we're covering all of them. periodt. ๐
โจ altDown โจ
altDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the Alt key is pressed. ๐ฆ
Bestie, real talk: wxKeyEvent:getModifiers/1 should usually be used instead of this one. ๐
โจ aux1DClick โจ
aux1DClick(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a first extra button double click. ๐ฑ๏ธ๐
โจ aux1Down โจ
aux1Down(This) -> boolean() when This :: wxMouseEvent().
Returns true if the first extra button mouse button changed to down. ๐โจ
โจ aux1Up โจ
aux1Up(This) -> boolean() when This :: wxMouseEvent().
Returns true if the first extra button mouse button changed to up. ๐๐ซ
โจ aux2DClick โจ
aux2DClick(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a second extra button double click. ๐ฑ๏ธ๐ฑ๏ธ๐ธ
โจ aux2Down โจ
aux2Down(This) -> boolean() when This :: wxMouseEvent().
Returns true if the second extra button mouse button changed to down. ๐๐
โจ aux2Up โจ
aux2Up(This) -> boolean() when This :: wxMouseEvent().
Returns true if the second extra button mouse button changed to up. ๐๐ฆ
โจ button โจ
button(This, But) -> boolean()
when This :: wxMouseEvent(), But :: wx:wx_enum().
Returns true if the event was generated by the specified button. no cap, it's checking exactly which button you mean. ๐ฏ
โจ buttonDClick โจ
buttonDClick(This, [Option]) -> boolean()
when
This :: wxMouseEvent(),
Option :: {but, wx:wx_enum()}.
If the argument is omitted, this returns true if the event was a mouse double click event. ๐ฅ
Otherwise the argument specifies which double click event was generated (see button/2 for the possible values). ๐
โจ buttonDown โจ
buttonDown(This, [Option]) -> boolean()
when
This :: wxMouseEvent(),
Option :: {but, wx:wx_enum()}.
If the argument is omitted, this returns true if the event was a mouse button down event. โฌ๏ธ
Otherwise the argument specifies which button-down event was generated (see button/2 for the possible values). ๐
โจ buttonUp โจ
buttonUp(This, [Option]) -> boolean()
when
This :: wxMouseEvent(),
Option :: {but, wx:wx_enum()}.
If the argument is omitted, this returns true if the event was a mouse button up event. โฌ๏ธ
Otherwise the argument specifies which button-up event was generated (see button/2 for the possible values). โจ
โจ cmdDown โจ
cmdDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the key used for command accelerators is pressed. โ
Same as controlDown/1. Deprecated. ๐ (she's retired bestie, do not build your whole personality on her)
Notice that wxKeyEvent:getModifiers/1 should usually be used instead of this one. ๐
โจ controlDown โจ
controlDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the Control key or Apple/Command key under macOS is pressed. ๐
This function doesn't distinguish between right and left control keys. ๐
Notice that wxKeyEvent:getModifiers/1 should usually be used instead of this one. ๐
โจ dragging โจ
dragging(This) -> boolean() when This :: wxMouseEvent().
Returns true if this was a dragging event (motion while a button is depressed). ๐๏ธ๐ซ
See: moving/1
โจ entering โจ
entering(This) -> boolean() when This :: wxMouseEvent().
Returns true if the mouse was entering the window. ๐ชโจ
See: leaving/1
โจ getButton โจ
getButton(This) -> integer() when This :: wxMouseEvent().
Returns the mouse button which generated this event or wxMOUSE_BTN_NONE if no button is involved (for mouse move, enter or leave event, for example). ๐ซฅ
Otherwise wxMOUSE_BTN_LEFT is returned for the left button down, up and double click events, wxMOUSE_BTN_MIDDLE and wxMOUSE_BTN_RIGHT for the same events for the middle and the right buttons respectively. ๐๐
โจ getLinesPerAction โจ
getLinesPerAction(This) -> integer() when This :: wxMouseEvent().
Returns the configured number of lines (or whatever) to be scrolled per wheel action. ๐ก
Default value under most platforms is three. 3๏ธโฃ
โจ getLogicalPosition โจ
getLogicalPosition(This, Dc) -> {X :: integer(), Y :: integer()}
when
This :: wxMouseEvent(),
Dc :: wxDC:wxDC().
Returns the logical mouse position in pixels (i.e. translated according to the translation set for the DC, which usually indicates that the window has been scrolled). ๐บ๏ธโจ
โจ getPosition โจ
getPosition(This) -> {X :: integer(), Y :: integer()}
when This :: wxMouseEvent().
Returns the physical mouse position. ๐
โจ getWheelAxis โจ
getWheelAxis(This) -> wx:wx_enum() when This :: wxMouseEvent().
Gets the axis the wheel operation concerns. ๐๏ธ
Usually the mouse wheel is used to scroll vertically so wxMOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads) also allow to use the wheel to scroll horizontally in which case wxMOUSE_WHEEL_HORIZONTAL is returned. ๐ฑ๏ธโ๏ธ
Notice that before wxWidgets 2.9.4 this method returned int. ๐
โจ getWheelDelta โจ
getWheelDelta(This) -> integer() when This :: wxMouseEvent().
Get wheel delta, normally 120. ๐
This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta. 1๏ธโฃ2๏ธโฃ0๏ธโฃ
โจ getWheelRotation โจ
getWheelRotation(This) -> integer() when This :: wxMouseEvent().
Get wheel rotation, positive or negative indicates direction of rotation. ๐
Current devices all send an event when rotation is at least +/-WheelDelta, but finer resolution devices can be created in the future. ๐ฎ
Because of this you shouldn't assume that one event is equal to 1 line, but you should be able to either do partial line scrolling or wait until several events accumulate before scrolling. ๐ง โจ
โจ getX โจ
getX(This) -> integer() when This :: wxMouseEvent().
Returns X coordinate of the physical mouse event position. โก๏ธ
โจ getY โจ
getY(This) -> integer() when This :: wxMouseEvent().
Returns Y coordinate of the physical mouse event position. โฌ๏ธ
โจ isButton โจ
isButton(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a mouse button event (not necessarily a button down event - that may be tested using buttonDown/2). ๐ฑ๏ธ
โจ isPageScroll โจ
isPageScroll(This) -> boolean() when This :: wxMouseEvent().
Returns true if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling. ๐โจ
โจ leaving โจ
leaving(This) -> boolean() when This :: wxMouseEvent().
Returns true if the mouse was leaving the window. ๐ช๐
See: entering/1
โจ leftDClick โจ
leftDClick(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a left double click. ๐ฑ๏ธ๐ฅ
โจ leftDown โจ
leftDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the left mouse button changed to down. ๐
โจ leftIsDown โจ
leftIsDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the left mouse button is currently down. ๐ซณ
โจ leftUp โจ
leftUp(This) -> boolean() when This :: wxMouseEvent().
Returns true if the left mouse button changed to up. ๐
โจ metaDown โจ
metaDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the Meta key was down at the time of the event. ๐ช
โจ middleDClick โจ
middleDClick(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a middle double click. ๐ฑ๏ธ๐ฅ
โจ middleDown โจ
middleDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the middle mouse button changed to down. ๐
โจ middleIsDown โจ
middleIsDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the middle mouse button is currently down. ๐ซณ
โจ middleUp โจ
middleUp(This) -> boolean() when This :: wxMouseEvent().
Returns true if the middle mouse button changed to up. ๐
โจ moving โจ
moving(This) -> boolean() when This :: wxMouseEvent().
Returns true if this was a motion event and no mouse buttons were pressed. ๐ฆ
If any mouse button is held pressed, then this method returns false and dragging/1 returns true. ๐๏ธ
โจ rightDClick โจ
rightDClick(This) -> boolean() when This :: wxMouseEvent().
Returns true if the event was a right double click. ๐ฑ๏ธ๐ฅ
โจ rightDown โจ
rightDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the right mouse button changed to down. ๐
โจ rightIsDown โจ
rightIsDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the right mouse button is currently down. ๐ซณ
โจ rightUp โจ
rightUp(This) -> boolean() when This :: wxMouseEvent().
Returns true if the right mouse button changed to up. ๐
โจ shiftDown โจ
shiftDown(This) -> boolean() when This :: wxMouseEvent().
Returns true if the Shift key is pressed. โฌ๏ธ
This function doesn't distinguish between right and left shift keys. ๐
Notice that wxKeyEvent:getModifiers/1 should usually be used instead of this one. ๐
and that's the whole function roster, bestie โ every single one accounted for, nothing ghosted, no cap. ๐ซถ
this iconic little page was served up by Ericsson AB, rocking version wx 2.6, and it's literally called wxMouseEvent(3) โ mwah ๐โจ
๐ฆ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms