Package wx :: Class MouseEvent
[frames | no frames]

Type MouseEvent

object --+        
         |        
    Object --+    
             |    
         Event --+
                 |
                MouseEvent


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 that not all mice have a middle button so a portable application should avoid relying on the events from it.

Note the difference between methods like LeftDown and 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 to test whether the left mouse button is (still) depressed. Also, by convention, if LeftDown returns true, 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.

Events

EVT_LEFT_DOWN Left mouse button 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.
EVT_LEFT_UP Left mouse button up event
EVT_LEFT_DCLICK Left mouse button double click event
EVT_MIDDLE_DOWN Middle mouse button down event
EVT_MIDDLE_UP Middle mouse button up event
EVT_MIDDLE_DCLICK Middle mouse button double click event
EVT_RIGHT_DOWN Right mouse button down event
EVT_RIGHT_UP Right mouse button up event
EVT_RIGHT_DCLICK Right mouse button double click event
EVT_MOTION Event sent when the mouse is moving
EVT_ENTER_WINDOW Event sent when the mouse enters the boundaries of a window.
EVT_LEAVE_WINDOW Sent when the mouse leaves the window's bounds
EVT_MOUSEWHEEL Mouse scroll wheel event
EVT_MOUSE_EVENTS Binds all mouse events at once.

Method Summary
MouseEvent __init__(self, mouseType)
Constructs a wx.MouseEvent.
bool AltDown(self)
Returns true if the Alt key was down at the time of the event.
bool ButtonDClick(self, but)
If the argument is omitted, this returns true if the event was any mouse double click event.
bool ButtonDown(self, but)
If the argument is omitted, this returns true if the event was any mouse button down event.
bool ButtonIsDown(self, but)
bool ButtonUp(self, but)
If the argument is omitted, this returns true if the event was any mouse button up event.
bool CmdDown(self)
"Cmd" is a pseudo key which is the same as Control for PC and Unix platforms but the special "Apple" (a.k.a as "Command") key on Macs.
bool ControlDown(self)
Returns true if the control key was down at the time of the event.
bool Dragging(self)
Returns true if this was a dragging event (motion while a button is depressed).
bool Entering(self)
Returns true if the mouse was entering the window.
int GetButton(self)
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).
int GetLinesPerAction(self)
Returns the configured number of lines (or whatever) to be scrolled per wheel action.
Point GetLogicalPosition(self, dc)
Returns the logical mouse position in pixels (i.e.
Point GetPosition(self)
Returns the pixel position of the mouse in window coordinates when the event happened.
(x,y) GetPositionTuple()
Returns the pixel position of the mouse in window coordinates when the event happened.
int GetWheelDelta(self)
Get wheel delta, normally 120.
int GetWheelRotation(self)
Get wheel rotation, positive or negative indicates direction of rotation.
int GetX(self)
Returns X coordinate of the physical mouse event position.
int GetY(self)
Returns Y coordinate of the physical mouse event position.
bool IsButton(self)
Returns true if the event was a mouse button event (not necessarily a button down event - that may be tested using ButtonDown).
bool IsPageScroll(self)
Returns true if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling.
bool Leaving(self)
Returns true if the mouse was leaving the window.
bool LeftDClick(self)
Returns true if the event was a left button double click.
bool LeftDown(self)
Returns true if the left mouse button state changed to down.
bool LeftIsDown(self)
Returns true if the left mouse button is currently down, independent of the current event type.
bool LeftUp(self)
Returns true if the left mouse button state changed to up.
bool MetaDown(self)
Returns true if the Meta key was down at the time of the event.
bool MiddleDClick(self)
Returns true if the event was a middle button double click.
bool MiddleDown(self)
Returns true if the middle mouse button state changed to down.
bool MiddleIsDown(self)
Returns true if the middle mouse button is currently down, independent of the current event type.
bool MiddleUp(self)
Returns true if the middle mouse button state changed to up.
bool Moving(self)
Returns true if this was a motion event and no mouse buttons were pressed.
bool RightDClick(self)
Returns true if the event was a right button double click.
bool RightDown(self)
Returns true if the right mouse button state changed to down.
bool RightIsDown(self)
Returns true if the right mouse button is currently down, independent of the current event type.
bool RightUp(self)
Returns true if the right mouse button state changed to up.
bool ShiftDown(self)
Returns true if the Shift key was down at the time of the event.

Property Summary
  Button: See GetButton
  LinesPerAction: See GetLinesPerAction
  LogicalPosition: See GetLogicalPosition
  m_altDown
  m_controlDown
  m_leftDown
  m_linesPerAction
  m_metaDown
  m_middleDown
  m_rightDown
  m_shiftDown
  m_wheelDelta
  m_wheelRotation
  m_x
  m_y
  Position: See GetPosition
  thisown: The membership flag
  WheelDelta: See GetWheelDelta
  WheelRotation: See GetWheelRotation
  X: See GetX
  Y: See GetY

Method Details

__init__(self, mouseType=wxEVT_NULL)
(Constructor)

Constructs a wx.MouseEvent. Valid event types are:

  • wxEVT_ENTER_WINDOW
  • wxEVT_LEAVE_WINDOW
  • wxEVT_LEFT_DOWN
  • wxEVT_LEFT_UP
  • wxEVT_LEFT_DCLICK
  • wxEVT_MIDDLE_DOWN
  • wxEVT_MIDDLE_UP
  • wxEVT_MIDDLE_DCLICK
  • wxEVT_RIGHT_DOWN
  • wxEVT_RIGHT_UP
  • wxEVT_RIGHT_DCLICK
  • wxEVT_MOTION
  • wxEVT_MOUSEWHEEL
Parameters:
mouseType
           (type=EventType)

Returns:
MouseEvent
Overrides:
wx.Event.__init__

AltDown(self)

Returns true if the Alt key was down at the time of the event.

Returns:
bool

ButtonDClick(self, but=MOUSE_BTN_ANY)

If the argument is omitted, this returns true if the event was any mouse double click event. Otherwise the argument specifies which double click event to check for (see Button for the possible values).

Parameters:
but
           (type=int)

Returns:
bool

ButtonDown(self, but=MOUSE_BTN_ANY)

If the argument is omitted, this returns true if the event was any mouse button down event. Otherwise the argument specifies which button-down event shold be checked for (see Button for the possible values).

Parameters:
but
           (type=int)

Returns:
bool

ButtonUp(self, but=MOUSE_BTN_ANY)

If the argument is omitted, this returns true if the event was any mouse button up event. Otherwise the argument specifies which button up event to check for (see Button for the possible values).

Parameters:
but
           (type=int)

Returns:
bool

CmdDown(self)

"Cmd" is a pseudo key which is the same as Control for PC and Unix platforms but the special "Apple" (a.k.a as "Command") key on Macs. It often makes sense to use it instead of, say, ControlDown because Cmd key is used for the same thing under Mac as Ctrl elsewhere. The Ctrl key still exists, it's just not used for this purpose. So for non-Mac platforms this is the same as ControlDown and Macs this is the same as MetaDown.

Returns:
bool

ControlDown(self)

Returns true if the control key was down at the time of the event.

Returns:
bool

Dragging(self)

Returns true if this was a dragging event (motion while a button is depressed).

Returns:
bool

Entering(self)

Returns true if the mouse was entering the window.

Returns:
bool

GetButton(self)

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

GetLinesPerAction(self)

Returns the configured number of lines (or whatever) to be scrolled per wheel action. Defaults to three.

Returns:
int

GetLogicalPosition(self, 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
           (type=DC)

Returns:
Point

GetPosition(self)

Returns the pixel position of the mouse in window coordinates when the event happened.

Returns:
Point

GetPositionTuple()

Returns the pixel position of the mouse in window coordinates when the event happened.

Returns:
(x,y)

GetWheelDelta(self)

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

GetWheelRotation(self)

Get wheel rotation, positive or negative indicates direction of rotation. Current devices all send an event when rotation is equal to +/-WheelDelta, but this allows for finer resolution devices to be created in the future. Because of this you shouldn't assume that one event is equal to 1 line or whatever, but you should be able to either do partial line scrolling or wait until +/-WheelDelta rotation values have been accumulated before scrolling.

Returns:
int

GetX(self)

Returns X coordinate of the physical mouse event position.

Returns:
int

GetY(self)

Returns Y coordinate of the physical mouse event position.

Returns:
int

IsButton(self)

Returns true if the event was a mouse button event (not necessarily a button down event - that may be tested using ButtonDown).

Returns:
bool

IsPageScroll(self)

Returns true if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling.

Returns:
bool

Leaving(self)

Returns true if the mouse was leaving the window.

Returns:
bool

LeftDClick(self)

Returns true if the event was a left button double click.

Returns:
bool

LeftDown(self)

Returns true if the left mouse button state changed to down.

Returns:
bool

LeftIsDown(self)

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 which returns true if the left mouse button was just pressed. Rather, it describes the state of the mouse button before the event happened.

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

LeftUp(self)

Returns true if the left mouse button state changed to up.

Returns:
bool

MetaDown(self)

Returns true if the Meta key was down at the time of the event.

Returns:
bool

MiddleDClick(self)

Returns true if the event was a middle button double click.

Returns:
bool

MiddleDown(self)

Returns true if the middle mouse button state changed to down.

Returns:
bool

MiddleIsDown(self)

Returns true if the middle mouse button is currently down, independent of the current event type.

Returns:
bool

MiddleUp(self)

Returns true if the middle mouse button state changed to up.

Returns:
bool

Moving(self)

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 returns true.

Returns:
bool

RightDClick(self)

Returns true if the event was a right button double click.

Returns:
bool

RightDown(self)

Returns true if the right mouse button state changed to down.

Returns:
bool

RightIsDown(self)

Returns true if the right mouse button is currently down, independent of the current event type.

Returns:
bool

RightUp(self)

Returns true if the right mouse button state changed to up.

Returns:
bool

ShiftDown(self)

Returns true if the Shift key was down at the time of the event.

Returns:
bool

Property Details

Button

See GetButton

Get Method:
GetButton(self)

LinesPerAction

See GetLinesPerAction

Get Method:
GetLinesPerAction(self)

LogicalPosition

See GetLogicalPosition

Get Method:
GetLogicalPosition(self, dc)

Position

See GetPosition

Get Method:
GetPosition(self)

thisown

The membership flag

WheelDelta

See GetWheelDelta

Get Method:
GetWheelDelta(self)

WheelRotation

See GetWheelRotation

Get Method:
GetWheelRotation(self)

X

See GetX

Get Method:
GetX(self)

Y

See GetY

Get Method:
GetY(self)

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:14:34 2007 http://epydoc.sf.net