wxMouseEvent(3)

๐Ÿ“ฆ
version 29.0.6 ยท 3 versions
, in ubuntu stonking

๐ŸŽ€ 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 like leftDown/1 and the inherited leftIsDown/1. Here's the tea: - leftDown/1 returns true when the event corresponds to the left mouse button click - leftIsDown/1 returns true if the left mouse button is currently being pressed So for example, when the user is dragging the mouse, you can use leftIsDown/1 to test whether the left mouse button is (still) depressed. ๐Ÿ’€ Also, by convention, if leftDown/1 returns true, then leftIsDown/1 will also return true in 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