************* wx.MouseEvent ************* Inheritance diagram for `wx.MouseEvent`: | .. inheritance-diagram:: wx.MouseEvent | Description =========== This event class contains information about the events generated by the mouse: they include mouse buttons press and release events and mouse move events. All mouse events involving the buttons use ``wx.MOUSE_BTN_LEFT`` for the left mouse button, ``wx.MOUSE_BTN_MIDDLE`` for the middle one and ``wx.MOUSE_BTN_RIGHT`` for the right one. .. note:: Note that not all mice have a middle button so a portable application should avoid relying on the events from it. .. note:: Note the difference between methods like `LeftDown <#LeftDown>`_ and `LeftIsDown <#LeftIsDown>`_: the former returns ``True`` when the event corresponds to the left mouse button click while the latter returns ``True`` if the left mouse button is currently being pressed. For example, when the user is dragging the mouse you can use `LeftIsDown <#LeftIsDown>`_ to test whether the left mouse button is (still) depressed. Also, by convention, if `LeftDown <#LeftDown>`_ returns ``True``, `LeftIsDown <#LeftIsDown>`_ will also return ``True`` in wxWidgets whatever the underlying GUI behaviour is (which is platform-dependent). The same applies, of course, to other mouse buttons as well. Derived From ^^^^^^^^^^^^^ * `wx.Event `_ Event Handling ^^^^^^^^^^^^^^ ================================================== ================================================== Event Name Description ================================================== ================================================== wx.EVT_LEFT_DOWN(func) Process a ``wx.wxEVT_LEFT_DOWN`` event. The handler of this event should normally call `event.Skip()` to allow the default processing to take place as otherwise the window under mouse wouldn't get the focus. wx.EVT_LEFT_UP(func) Process a ``wx.wxEVT_LEFT_UP`` event. wx.EVT_LEFT_DCLICK(func) Process a ``wx.wxEVT_LEFT_DCLICK`` event. wx.EVT_MIDDLE_DOWN(func) Process a ``wx.wxEVT_MIDDLE_DOWN`` event. wx.EVT_MIDDLE_UP(func) Process a ``wx.wxEVT_MIDDLE_UP`` event. wx.EVT_MIDDLE_DCLICK(func) Process a ``wx.wxEVT_MIDDLE_DCLICK`` event. wx.EVT_RIGHT_DOWN(func) Process a ``wx.wxEVT_RIGHT_DOWN`` event. wx.EVT_RIGHT_UP(func) Process a ``wx.wxEVT_RIGHT_UP`` event. wx.EVT_RIGHT_DCLICK(func) Process a ``wx.wxEVT_RIGHT_DCLICK`` event. wx.EVT_MOTION(func) Process a ``wx.wxEVT_MOTION`` event. wx.EVT_ENTER_WINDOW(func) Process a ``wx.wxEVT_ENTER_WINDOW`` event. wx.EVT_LEAVE_WINDOW(func) Process a ``wx.wxEVT_LEAVE_WINDOW`` event. wx.EVT_MOUSEWHEEL(func) Process a ``wx.wxEVT_MOUSEWHEEL`` event. wx.EVT_MOUSE_EVENTS(func) Process all mouse events. ================================================== ================================================== Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `AltDown <#AltDown>`_ * `ButtonDClick <#ButtonDClick>`_ * `ButtonDown <#ButtonDown>`_ * `ButtonIsDown <#ButtonIsDown>`_ * `ButtonUp <#ButtonUp>`_ * `CmdDown <#CmdDown>`_ * `ControlDown <#ControlDown>`_ * `Dragging <#Dragging>`_ * `Entering <#Entering>`_ * `GetButton <#GetButton>`_ * `GetLinesPerAction <#GetLinesPerAction>`_ * `GetLogicalPosition <#GetLogicalPosition>`_ * `GetPosition <#GetPosition>`_ * `GetPositionTuple <#GetPositionTuple>`_ * `GetWheelDelta <#GetWheelDelta>`_ * `GetWheelRotation <#GetWheelRotation>`_ * `GetX <#GetX>`_ * `GetY <#GetY>`_ * `IsButton <#IsButton>`_ * `IsPageScroll <#IsPageScroll>`_ * `Leaving <#Leaving>`_ * `LeftDClick <#LeftDClick>`_ * `LeftDown <#LeftDown>`_ * `LeftIsDown <#LeftIsDown>`_ * `LeftUp <#LeftUp>`_ * `MetaDown <#MetaDown>`_ * `MiddleDClick <#MiddleDClick>`_ * `MiddleDown <#MiddleDown>`_ * `MiddleIsDown <#MiddleIsDown>`_ * `MiddleUp <#MiddleUp>`_ * `Moving <#Moving>`_ * `RightDClick <#RightDClick>`_ * `RightDown <#RightDown>`_ * `RightIsDown <#RightIsDown>`_ * `RightUp <#RightUp>`_ * `ShiftDown <#ShiftDown>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Button <#Button>`_ * `LinesPerAction <#LinesPerAction>`_ * `LogicalPosition <#LogicalPosition>`_ * `Position <#Position>`_ * `WheelDelta <#WheelDelta>`_ * `WheelRotation <#WheelRotation>`_ * `X <#X>`_ * `Y <#Y>`_ * `m_altDown <#m_altDown>`_ * `m_controlDown <#m_controlDown>`_ * `m_leftDown <#m_leftDown>`_ * `m_linesPerAction <#m_linesPerAction>`_ * `m_metaDown <#m_metaDown>`_ * `m_middleDown <#m_middleDown>`_ * `m_rightDown <#m_rightDown>`_ * `m_shiftDown <#m_shiftDown>`_ * `m_wheelDelta <#m_wheelDelta>`_ * `m_wheelRotation <#m_wheelRotation>`_ * `m_x <#m_x>`_ * `m_y <#m_y>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(mouseType=wx.wxEVT_NULL) Constructs a `wx.MouseEvent`. Valid event types are: * wx.EVT_ENTER_WINDOW * wx.EVT_LEAVE_WINDOW * wx.EVT_LEFT_DOWN * wx.EVT_LEFT_UP * wx.EVT_LEFT_DCLICK * wx.EVT_MIDDLE_DOWN * wx.EVT_MIDDLE_UP * wx.EVT_MIDDLE_DCLICK * wx.EVT_RIGHT_DOWN * wx.EVT_RIGHT_UP * wx.EVT_RIGHT_DCLICK * wx.EVT_MOTION * wx.EVT_MOUSEWHEEL **Parameters:** * `mouseType` (eventtype) | **Returns:** `wx.MouseEvent `_ -------- .. method:: AltDown() Returns ``True`` if the ``Alt`` key was down at the time of the event. | **Returns:** `bool` -------- .. method:: ButtonDClick(but=wx.MOUSE_BTN_ANY) 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 `GetButton <#GetButton>`_ for the possible values). **Parameters:** * `but` (int) | **Returns:** `bool` -------- .. method:: ButtonDown(but=-1) 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 `GetButton <#GetButton>`_ for the possible values). **Parameters:** * `but` (int) | **Returns:** `bool` -------- .. method:: ButtonIsDown(but) | **Parameters:** * `but` (int) | **Returns:** `bool` -------- .. method:: ButtonUp(but=-1) If the argument is omitted, this returns ``True`` if the event was a mouse button up event. Otherwise the argument specifies which button-down event was generated (see `GetButton <#GetButton>`_ for the possible values). **Parameters:** * `but` (int) | **Returns:** `bool` -------- .. method:: CmdDown() Same as `MetaDown <#MetaDown>`_ under Mac, same as `ControlDown <#ControlDown>`_ elsewhere. | **Returns:** `bool` .. seealso:: `wx.KeyEvent.CmdDown `_ -------- .. method:: ControlDown() Returns ``True`` if the control key was down at the time of the event. | **Returns:** `bool` -------- .. method:: Dragging() Returns ``True`` if this was a dragging event (motion while a button is depressed). | **Returns:** `bool` .. seealso:: `Moving <#Moving>`_ -------- .. method:: Entering() Returns ``True`` if the mouse was entering the window. | **Returns:** `bool` .. seealso:: `Leaving `_. -------- .. method:: GetButton() Returns the mouse button which generated this event or ``wx.MOUSE_BTN_NONE`` if no button is involved (for mouse move, enter or leave event, for example). Otherwise ``wx.MOUSE_BTN_LEFT`` is returned for the left button down, up and double click events, ``wx.MOUSE_BTN_MIDDLE`` and ``wx.MOUSE_BTN_RIGHT`` for the same events for the middle and the right buttons respectively. | **Returns:** `int` -------- .. method:: GetLinesPerAction() Returns the configured number of lines (or whatever) to be scrolled per wheel action. Defaults to three. | **Returns:** `int` -------- .. method:: GetLogicalPosition(dc) 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). **Parameters:** * `dc` (`wx.DC <../Widgets/wx.DC.html>`_) | **Returns:** `wx.Point <../Widgets/wx.Point.html>`_ -------- .. method:: GetPosition() Returns the physical mouse position in pixels. | **Returns:** `wx.Point <../Widgets/wx.Point.html>`_ .. note:: Note that if the mouse event has been artificially generated from a special keyboard combination (e.g. under Windows when the "menu" key is pressed), the returned position is `wx.DefaultPosition`. -------- .. method:: GetPositionTuple() Returns the pixel position of the mouse in window coordinates when the event happened. | **Returns:** `(x,y)` -------- .. method:: GetWheelDelta() 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. | **Returns:** `int` -------- .. method:: GetWheelRotation() 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. | **Returns:** `int` -------- .. method:: GetX() Returns `X` coordinate of the physical mouse event position. | **Returns:** `long` -------- .. method:: GetY() Returns `Y` coordinate of the physical mouse event position. | **Returns:** `long` -------- .. method:: IsButton() Returns ``True`` if the event was a mouse button event (not necessarily a button down event - that may be tested using `ButtonDown <#ButtonDown>`_). | **Returns:** `bool` -------- .. method:: IsPageScroll() Returns ``True`` if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling. | **Returns:** `bool` -------- .. method:: Leaving() Returns ``True`` if the mouse was leaving the window. | **Returns:** `bool` .. seealso:: `Entering <#Entering>`_. -------- .. method:: LeftDClick() Returns ``True`` if the event was a left double click. | **Returns:** `bool` -------- .. method:: LeftDown() Returns ``True`` if the left mouse button changed to down. | **Returns:** `bool` -------- .. method:: LeftIsDown() Returns ``True`` if the left mouse button is currently down, independent of the current event type. Please notice that it is **not** the same as `LeftDown <#LeftDown>`_ which returns ``True`` if the event was generated by the left mouse button being pressed. Rather, it simply describes the state of the left mouse button at the time when the event was generated (so while it will be ``True`` for a left click event, it can also be ``True`` for a right click if it happened while the left mouse button was pressed). This event is usually used in the mouse event handlers which process "move mouse" messages to determine whether the user is (still) dragging the mouse. | **Returns:** `bool` -------- .. method:: LeftUp() Returns ``True`` if the left mouse button changed to up. | **Returns:** `bool` -------- .. method:: MetaDown() Returns ``True`` if the Meta key was down at the time of the event. | **Returns:** `bool` -------- .. method:: MiddleDClick() Returns ``True`` if the event was a middle double click. | **Returns:** `bool` -------- .. method:: MiddleDown() Returns ``True`` if the middle mouse button changed to down. | **Returns:** `bool` -------- .. method:: MiddleIsDown() Returns ``True`` if the middle mouse button is currently down, independent of the current event type. | **Returns:** `bool` -------- .. method:: MiddleUp() Returns ``True`` if the middle mouse button changed to up. | **Returns:** `bool` -------- .. method:: Moving() 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 <#Dragging>`_ returns ``True``. | **Returns:** `bool` -------- .. method:: RightDClick() Returns ``True`` if the event was a right double click. | **Returns:** `bool` -------- .. method:: RightDown() Returns ``True`` if the right mouse button changed to down. | **Returns:** `bool` -------- .. method:: RightIsDown() Returns ``True`` if the right mouse button is currently down, independent of the current event type. | **Returns:** `bool` -------- .. method:: RightUp() Returns ``True`` if the right mouse button changed to up. | **Returns:** `bool` -------- .. method:: ShiftDown() Returns ``True`` if the shift key was down at the time of the event. | **Returns:** `bool` -------- Properties ^^^^^^^^^^ .. attribute:: Button See `GetButton <#GetButton>`_ .. attribute:: LinesPerAction See `GetLinesPerAction <#GetLinesPerAction>`_ .. attribute:: LogicalPosition See `GetLogicalPosition <#GetLogicalPosition>`_ .. attribute:: Position See `GetPosition <#GetPosition>`_ .. attribute:: WheelDelta See `GetWheelDelta <#GetWheelDelta>`_ .. attribute:: WheelRotation See `GetWheelRotation <#GetWheelRotation>`_ .. attribute:: X See `GetX <#GetX>`_ .. attribute:: Y See `GetY <#GetY>`_ .. attribute:: m_altDown See `AltDown <#AltDown>`_ .. attribute:: m_controlDown See `ControlDown <#ControlDown>`_ .. attribute:: m_leftDown See `LeftDown <#LeftDown>`_ .. attribute:: m_linesPerAction See `GetLinesPerAction <#GetLinesPerAction>`_ .. attribute:: m_metaDown See `MetaDown <#MetaDown>`_ .. attribute:: m_middleDown See `MiddleDown <#MiddleDown>`_ .. attribute:: m_rightDown See `RightDown <#RightDown>`_ .. attribute:: m_shiftDown See `ShiftDown <#ShiftDown>`_ .. attribute:: m_wheelDelta See `GetWheelDelta <#GetWheelDelta>`_ .. attribute:: m_wheelRotation See `GetWheelRotation <#GetWheelRotation>`_ .. attribute:: m_x See `GetX <#GetX>`_ .. attribute:: m_y See `GetY <#GetY>`_