1 \section{\class{wxMouseEvent
}}\label{wxmouseevent
}
3 This event class contains information about the events generated by the mouse:
4 they include mouse buttons press and release events and mouse move events.
6 All mouse events involving the buttons use
{\tt wxMOUSE
\_BTN\_LEFT} for the
7 left mouse button,
{\tt wxMOUSE
\_BTN\_MIDDLE} for the middle one and
8 {\tt wxMOUSE
\_BTN\_RIGHT} for the right one. Note that not all mice have a
9 middle button so a portable application should avoid relying on the events from
12 For the
\texttt{wxEVT
\_ENTER\_WINDOW} and
\texttt{wxEVT
\_LEAVE\_WINDOW} events
13 purposes, the mouse is considered to be inside the window if it is in the
14 window client area and not inside one of its children. In other words, the
15 parent window receives
\texttt{wxEVT
\_LEAVE\_WINDOW} event not only when the
16 mouse leaves the window entirely but also when it enters one of its children.
18 {\bf NB:
} Note that under Windows CE mouse enter and leave events are not natively supported
19 by the system but are generated by wxWidgets itself. This has several
20 drawbacks: the LEAVE
\_WINDOW event might be received some time after the mouse
21 left the window and the state variables for it may have changed during this
24 {\bf NB:
} Note the difference between methods like
25 \helpref{LeftDown
}{wxmouseeventleftdown
} and
26 \helpref{LeftIsDown
}{wxmouseeventleftisdown
}: the former returns
{\tt true
}
27 when the event corresponds to the left mouse button click while the latter
28 returns
{\tt true
} if the left mouse button is currently being pressed. For
29 example, when the user is dragging the mouse you can use
30 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} to test
31 whether the left mouse button is (still) depressed. Also, by convention, if
32 \helpref{LeftDown
}{wxmouseeventleftdown
} returns
{\tt true
},
33 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} will also return
{\tt true
} in
34 wxWidgets whatever the underlying GUI behaviour is (which is
35 platform-dependent). The same applies, of course, to other mouse buttons as
38 \wxheading{Derived from
}
40 \helpref{wxEvent
}{wxevent
}
42 \wxheading{Include files
}
46 \wxheading{Event table macros
}
48 To process a mouse event, use these event handler macros to direct input to member
49 functions that take a wxMouseEvent argument.
52 \begin{twocollist
}\itemsep=
0pt
53 \twocolitem{{\bf EVT
\_LEFT\_DOWN(func)
}}{Process a wxEVT
\_LEFT\_DOWN event. The
54 handler of this event should normally call
\helpref{event.Skip()
}{wxeventskip
} to
55 allow the default processing to take place as otherwise the window under mouse
56 wouldn't get the focus.
}
57 \twocolitem{{\bf EVT
\_LEFT\_UP(func)
}}{Process a wxEVT
\_LEFT\_UP event.
}
58 \twocolitem{{\bf EVT
\_LEFT\_DCLICK(func)
}}{Process a wxEVT
\_LEFT\_DCLICK event.
}
59 \twocolitem{{\bf EVT
\_MIDDLE\_DOWN(func)
}}{Process a wxEVT
\_MIDDLE\_DOWN event.
}
60 \twocolitem{{\bf EVT
\_MIDDLE\_UP(func)
}}{Process a wxEVT
\_MIDDLE\_UP event.
}
61 \twocolitem{{\bf EVT
\_MIDDLE\_DCLICK(func)
}}{Process a wxEVT
\_MIDDLE\_DCLICK event.
}
62 \twocolitem{{\bf EVT
\_RIGHT\_DOWN(func)
}}{Process a wxEVT
\_RIGHT\_DOWN event.
}
63 \twocolitem{{\bf EVT
\_RIGHT\_UP(func)
}}{Process a wxEVT
\_RIGHT\_UP event.
}
64 \twocolitem{{\bf EVT
\_RIGHT\_DCLICK(func)
}}{Process a wxEVT
\_RIGHT\_DCLICK event.
}
65 \twocolitem{{\bf EVT
\_MOTION(func)
}}{Process a wxEVT
\_MOTION event.
}
66 \twocolitem{{\bf EVT
\_ENTER\_WINDOW(func)
}}{Process a wxEVT
\_ENTER\_WINDOW event.
}
67 \twocolitem{{\bf EVT
\_LEAVE\_WINDOW(func)
}}{Process a wxEVT
\_LEAVE\_WINDOW event.
}
68 \twocolitem{{\bf EVT
\_MOUSEWHEEL(func)
}}{Process a wxEVT
\_MOUSEWHEEL event.
}
69 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
72 \latexignore{\rtfignore{\wxheading{Members
}}}
75 \membersection{wxMouseEvent::m
\_altDown}\label{wxmouseeventmaltdown
}
77 \member{bool
}{m
\_altDown}
79 true if the Alt key is pressed down.
82 \membersection{wxMouseEvent::m
\_controlDown}\label{wxmouseeventmcontroldown
}
84 \member{bool
}{m
\_controlDown}
86 true if control key is pressed down.
89 \membersection{wxMouseEvent::m
\_leftDown}\label{wxmouseeventmleftdown
}
91 \member{bool
}{m
\_leftDown}
93 true if the left mouse button is currently pressed down.
96 \membersection{wxMouseEvent::m
\_middleDown}\label{wxmouseeventmmiddledown
}
98 \member{bool
}{m
\_middleDown}
100 true if the middle mouse button is currently pressed down.
103 \membersection{wxMouseEvent::m
\_rightDown}\label{wxmouseeventmrightdown
}
105 \member{bool
}{m
\_rightDown}
107 true if the right mouse button is currently pressed down.
110 \membersection{wxMouseEvent::m
\_metaDown}\label{wxmouseeventmmetadown
}
112 \member{bool
}{m
\_metaDown}
114 true if the Meta key is pressed down.
117 \membersection{wxMouseEvent::m
\_shiftDown}\label{wxmouseeventmshiftdown
}
119 \member{bool
}{m
\_shiftDown}
121 true if shift is pressed down.
124 \membersection{wxMouseEvent::m
\_x}\label{wxmouseeventmx
}
128 X-coordinate of the event.
131 \membersection{wxMouseEvent::m
\_y}\label{wxmouseeventmy
}
135 Y-coordinate of the event.
138 \membersection{wxMouseEvent::m
\_wheelRotation}\label{wxmouseeventmwheelrotation
}
140 \member{int
}{m
\_wheelRotation}
142 The distance the mouse wheel is rotated.
145 \membersection{wxMouseEvent::m
\_wheelDelta}\label{wxmouseeventmwheeldelta
}
147 \member{int
}{m
\_wheelDelta}
149 The wheel delta, normally $
120$.
152 \membersection{wxMouseEvent::m
\_linesPerAction}\label{wxmouseeventmlinesperaction
}
154 \member{int
}{m
\_linesPerAction}
156 The configured number of lines (or whatever) to be scrolled per wheel
161 \membersection{wxMouseEvent::wxMouseEvent
}\label{wxmouseeventctor
}
163 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0}}
165 Constructor. Valid event types are:
169 \item {\bf wxEVT
\_ENTER\_WINDOW}
170 \item {\bf wxEVT
\_LEAVE\_WINDOW}
171 \item {\bf wxEVT
\_LEFT\_DOWN}
172 \item {\bf wxEVT
\_LEFT\_UP}
173 \item {\bf wxEVT
\_LEFT\_DCLICK}
174 \item {\bf wxEVT
\_MIDDLE\_DOWN}
175 \item {\bf wxEVT
\_MIDDLE\_UP}
176 \item {\bf wxEVT
\_MIDDLE\_DCLICK}
177 \item {\bf wxEVT
\_RIGHT\_DOWN}
178 \item {\bf wxEVT
\_RIGHT\_UP}
179 \item {\bf wxEVT
\_RIGHT\_DCLICK}
180 \item {\bf wxEVT
\_MOTION}
181 \item {\bf wxEVT
\_MOUSEWHEEL}
185 \membersection{wxMouseEvent::AltDown
}\label{wxmouseeventaltdown
}
187 \func{bool
}{AltDown
}{\void}
189 Returns true if the Alt key was down at the time of the event.
192 \membersection{wxMouseEvent::Button
}\label{wxmouseeventbutton
}
194 \func{bool
}{Button
}{\param{int
}{ button
}}
196 Returns true if the identified mouse button is changing state. Valid
197 values of
{\it button
} are:
199 \begin{twocollist
}\itemsep=
0pt
200 \twocolitem{{\tt wxMOUSE
\_BTN\_LEFT}}{check if left button was pressed
}
201 \twocolitem{{\tt wxMOUSE
\_BTN\_MIDDLE}}{check if middle button was pressed
}
202 \twocolitem{{\tt wxMOUSE
\_BTN\_RIGHT}}{check if right button was pressed
}
203 \twocolitem{{\tt wxMOUSE
\_BTN\_ANY}}{check if any button was pressed
}
207 \membersection{wxMouseEvent::ButtonDClick
}\label{wxmouseeventbuttondclick
}
209 \func{bool
}{ButtonDClick
}{\param{int
}{ but = wxMOUSE
\_BTN\_ANY}}
211 If the argument is omitted, this returns true if the event was a mouse
212 double click event. Otherwise the argument specifies which double click event
213 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
217 \membersection{wxMouseEvent::ButtonDown
}\label{wxmouseeventbuttondown
}
219 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
221 If the argument is omitted, this returns true if the event was a mouse
222 button down event. Otherwise the argument specifies which button-down event
223 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
228 \membersection{wxMouseEvent::ButtonUp
}\label{wxmouseeventbuttonup
}
230 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
232 If the argument is omitted, this returns true if the event was a mouse
233 button up event. Otherwise the argument specifies which button-up event
234 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
239 \membersection{wxMouseEvent::CmdDown
}\label{wxmouseeventcmddown
}
241 \constfunc{bool
}{CmdDown
}{\void}
243 Same as
\helpref{MetaDown
}{wxmouseeventmetadown
} under Mac, same as
244 \helpref{ControlDown
}{wxmouseeventcontroldown
} elsewhere.
248 \helpref{wxKeyEvent::CmdDown
}{wxkeyeventcmddown
}
251 \membersection{wxMouseEvent::ControlDown
}\label{wxmouseeventcontroldown
}
253 \func{bool
}{ControlDown
}{\void}
255 Returns true if the control key was down at the time of the event.
258 \membersection{wxMouseEvent::Dragging
}\label{wxmouseeventdragging
}
260 \func{bool
}{Dragging
}{\void}
262 Returns true if this was a dragging event (motion while a button is depressed).
266 \helpref{Moving
}{wxmouseeventmoving
}
269 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
271 \func{bool
}{Entering
}{\void}
273 Returns true if the mouse was entering the window.
275 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
278 \membersection{wxMouseEvent::GetButton
}\label{wxmouseeventgetbutton
}
280 \constfunc{int
}{GetButton
}{\void}
282 Returns the mouse button which generated this event or
{\tt wxMOUSE
\_BTN\_NONE}
283 if no button is involved (for mouse move, enter or leave event, for example).
284 Otherwise
{\tt wxMOUSE
\_BTN\_LEFT} is returned for the left button down, up and
285 double click events,
{\tt wxMOUSE
\_BTN\_MIDDLE} and
{\tt wxMOUSE
\_BTN\_RIGHT}
286 for the same events for the middle and the right buttons respectively.
289 \membersection{wxMouseEvent::GetPosition
}\label{wxmouseeventgetposition
}
291 \constfunc{wxPoint
}{GetPosition
}{\void}
293 \constfunc{void
}{GetPosition
}{\param{wxCoord*
}{ x
},
\param{wxCoord*
}{ y
}}
295 \constfunc{void
}{GetPosition
}{\param{long*
}{ x
},
\param{long*
}{ y
}}
297 Sets *x and *y to the position at which the event occurred.
299 Returns the physical mouse position in pixels.
301 Note that if the mouse event has been artificially generated from a special
302 keyboard combination (e.g. under Windows when the ``menu'' key is pressed), the
303 returned position is
\texttt{wxDefaultPosition
}.
306 \membersection{wxMouseEvent::GetLogicalPosition
}\label{wxmouseeventgetlogicalposition
}
308 \constfunc{wxPoint
}{GetLogicalPosition
}{\param{const wxDC\&
}{ dc
}}
310 Returns the logical mouse position in pixels (i.e. translated according to the
311 translation set for the DC, which usually indicates that the window has been scrolled).
315 \membersection{wxMouseEvent::GetLinesPerAction
}\label{wxmouseeventgetlinesperaction
}
317 \constfunc{int
}{GetLinesPerAction
}{\void}
319 Returns the configured number of lines (or whatever) to be scrolled per
320 wheel action. Defaults to three.
323 \membersection{wxMouseEvent::GetWheelRotation
}\label{wxmouseeventgetwheelrotation
}
325 \constfunc{int
}{GetWheelRotation
}{\void}
327 Get wheel rotation, positive or negative indicates direction of
328 rotation. Current devices all send an event when rotation is at least
329 +/-WheelDelta, but finer resolution devices can be created in the future.
330 Because of this you shouldn't assume that one event is equal to
1 line, but you
331 should be able to either do partial line scrolling or wait until several
332 events accumulate before scrolling.
335 \membersection{wxMouseEvent::GetWheelDelta
}\label{wxmouseeventgetwheeldelta
}
337 \constfunc{int
}{GetWheelDelta
}{\void}
339 Get wheel delta, normally $
120$. This is the threshold for action to be
340 taken, and one such action (for example, scrolling one increment)
341 should occur for each delta.
344 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
346 \constfunc{long
}{GetX
}{\void}
348 Returns X coordinate of the physical mouse event position.
351 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
353 \func{long
}{GetY
}{\void}
355 Returns Y coordinate of the physical mouse event position.
358 \membersection{wxMouseEvent::IsButton
}\label{wxmouseeventisbutton
}
360 \constfunc{bool
}{IsButton
}{\void}
362 Returns true if the event was a mouse button event (not necessarily a button down event -
363 that may be tested using
{\it ButtonDown
}).
366 \membersection{wxMouseEvent::IsPageScroll
}\label{wxmouseeventispagescroll
}
368 \constfunc{bool
}{IsPageScroll
}{\void}
370 Returns true if the system has been setup to do page scrolling with
371 the mouse wheel instead of line scrolling.
374 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
376 \constfunc{bool
}{Leaving
}{\void}
378 Returns true if the mouse was leaving the window.
380 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
383 \membersection{wxMouseEvent::LeftDClick
}\label{wxmouseeventleftdclick
}
385 \constfunc{bool
}{LeftDClick
}{\void}
387 Returns true if the event was a left double click.
390 \membersection{wxMouseEvent::LeftDown
}\label{wxmouseeventleftdown
}
392 \constfunc{bool
}{LeftDown
}{\void}
394 Returns true if the left mouse button changed to down.
397 \membersection{wxMouseEvent::LeftIsDown
}\label{wxmouseeventleftisdown
}
399 \constfunc{bool
}{LeftIsDown
}{\void}
401 Returns true if the left mouse button is currently down, independent
402 of the current event type.
404 Please notice that it is
\emph{not
} the same as
405 \helpref{LeftDown
}{wxmouseeventleftdown
} which returns
\true if the event was
406 generated by the left mouse button being pressed. Rather, it simply describes
407 the state of the left mouse button at the time when the event was generated
408 (so while it will be true for a left click event, it can also be true for
409 a right click if it happened while the left mouse button was pressed).
411 This event is usually used in the mouse event handlers which process "move
412 mouse" messages to determine whether the user is (still) dragging the mouse.
415 \membersection{wxMouseEvent::LeftUp
}\label{wxmouseeventleftup
}
417 \constfunc{bool
}{LeftUp
}{\void}
419 Returns true if the left mouse button changed to up.
422 \membersection{wxMouseEvent::MetaDown
}\label{wxmouseeventmetadown
}
424 \constfunc{bool
}{MetaDown
}{\void}
426 Returns true if the Meta key was down at the time of the event.
429 \membersection{wxMouseEvent::MiddleDClick
}\label{wxmouseeventmiddledclick
}
431 \constfunc{bool
}{MiddleDClick
}{\void}
433 Returns true if the event was a middle double click.
436 \membersection{wxMouseEvent::MiddleDown
}\label{wxmouseeventmiddledown
}
438 \constfunc{bool
}{MiddleDown
}{\void}
440 Returns true if the middle mouse button changed to down.
443 \membersection{wxMouseEvent::MiddleIsDown
}\label{wxmouseeventmiddleisdown
}
445 \constfunc{bool
}{MiddleIsDown
}{\void}
447 Returns true if the middle mouse button is currently down, independent
448 of the current event type.
451 \membersection{wxMouseEvent::MiddleUp
}\label{wxmouseeventmiddleup
}
453 \constfunc{bool
}{MiddleUp
}{\void}
455 Returns true if the middle mouse button changed to up.
458 \membersection{wxMouseEvent::Moving
}\label{wxmouseeventmoving
}
460 \constfunc{bool
}{Moving
}{\void}
462 Returns true if this was a motion event and no mouse buttons were pressed.
463 If any mouse button is held pressed, then this method returns
\false and
464 \helpref{Dragging
}{wxmouseeventdragging
} returns
\true.
467 \membersection{wxMouseEvent::RightDClick
}\label{wxmouseeventrightdclick
}
469 \constfunc{bool
}{RightDClick
}{\void}
471 Returns true if the event was a right double click.
474 \membersection{wxMouseEvent::RightDown
}\label{wxmouseeventrightdown
}
476 \constfunc{bool
}{RightDown
}{\void}
478 Returns true if the right mouse button changed to down.
481 \membersection{wxMouseEvent::RightIsDown
}\label{wxmouseeventrightisdown
}
483 \constfunc{bool
}{RightIsDown
}{\void}
485 Returns true if the right mouse button is currently down, independent
486 of the current event type.
489 \membersection{wxMouseEvent::RightUp
}\label{wxmouseeventrightup
}
491 \constfunc{bool
}{RightUp
}{\void}
493 Returns true if the right mouse button changed to up.
496 \membersection{wxMouseEvent::ShiftDown
}\label{wxmouseeventshiftdown
}
498 \constfunc{bool
}{ShiftDown
}{\void}
500 Returns true if the shift key was down at the time of the event.