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 {\bf NB:
} Note that under Windows CE mouse enter and leave events are not natively supported
13 by the system but are generated by wxWidgets itself. This has several
14 drawbacks: the LEAVE
\_WINDOW event might be received some time after the mouse
15 left the window and the state variables for it may have changed during this
18 {\bf NB:
} Note the difference between methods like
19 \helpref{LeftDown
}{wxmouseeventleftdown
} and
20 \helpref{LeftIsDown
}{wxmouseeventleftisdown
}: the former returns
{\tt true
}
21 when the event corresponds to the left mouse button click while the latter
22 returns
{\tt true
} if the left mouse button is currently being pressed. For
23 example, when the user is dragging the mouse you can use
24 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} to test
25 whether the left mouse button is (still) depressed. Also, by convention, if
26 \helpref{LeftDown
}{wxmouseeventleftdown
} returns
{\tt true
},
27 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} will also return
{\tt true
} in
28 wxWidgets whatever the underlying GUI behaviour is (which is
29 platform-dependent). The same applies, of course, to other mouse buttons as
32 \wxheading{Derived from
}
34 \helpref{wxEvent
}{wxevent
}
36 \wxheading{Include files
}
40 \wxheading{Event table macros
}
42 To process a mouse event, use these event handler macros to direct input to member
43 functions that take a wxMouseEvent argument.
46 \begin{twocollist
}\itemsep=
0pt
47 \twocolitem{{\bf EVT
\_LEFT\_DOWN(func)
}}{Process a wxEVT
\_LEFT\_DOWN event. The
48 handler of this event should normally call
\helpref{event.Skip()
}{wxeventskip
} to
49 allow the default processing to take place as otherwise the window under mouse
50 wouldn't get the focus.
}
51 \twocolitem{{\bf EVT
\_LEFT\_UP(func)
}}{Process a wxEVT
\_LEFT\_UP event.
}
52 \twocolitem{{\bf EVT
\_LEFT\_DCLICK(func)
}}{Process a wxEVT
\_LEFT\_DCLICK event.
}
53 \twocolitem{{\bf EVT
\_MIDDLE\_DOWN(func)
}}{Process a wxEVT
\_MIDDLE\_DOWN event.
}
54 \twocolitem{{\bf EVT
\_MIDDLE\_UP(func)
}}{Process a wxEVT
\_MIDDLE\_UP event.
}
55 \twocolitem{{\bf EVT
\_MIDDLE\_DCLICK(func)
}}{Process a wxEVT
\_MIDDLE\_DCLICK event.
}
56 \twocolitem{{\bf EVT
\_RIGHT\_DOWN(func)
}}{Process a wxEVT
\_RIGHT\_DOWN event.
}
57 \twocolitem{{\bf EVT
\_RIGHT\_UP(func)
}}{Process a wxEVT
\_RIGHT\_UP event.
}
58 \twocolitem{{\bf EVT
\_RIGHT\_DCLICK(func)
}}{Process a wxEVT
\_RIGHT\_DCLICK event.
}
59 \twocolitem{{\bf EVT
\_MOTION(func)
}}{Process a wxEVT
\_MOTION event.
}
60 \twocolitem{{\bf EVT
\_ENTER\_WINDOW(func)
}}{Process a wxEVT
\_ENTER\_WINDOW event.
}
61 \twocolitem{{\bf EVT
\_LEAVE\_WINDOW(func)
}}{Process a wxEVT
\_LEAVE\_WINDOW event.
}
62 \twocolitem{{\bf EVT
\_MOUSEWHEEL(func)
}}{Process a wxEVT
\_MOUSEWHEEL event.
}
63 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
66 \latexignore{\rtfignore{\wxheading{Members
}}}
69 \membersection{wxMouseEvent::m
\_altDown}\label{wxmouseeventmaltdown
}
71 \member{bool
}{m
\_altDown}
73 true if the Alt key is pressed down.
76 \membersection{wxMouseEvent::m
\_controlDown}\label{wxmouseeventmcontroldown
}
78 \member{bool
}{m
\_controlDown}
80 true if control key is pressed down.
83 \membersection{wxMouseEvent::m
\_leftDown}\label{wxmouseeventmleftdown
}
85 \member{bool
}{m
\_leftDown}
87 true if the left mouse button is currently pressed down.
90 \membersection{wxMouseEvent::m
\_middleDown}\label{wxmouseeventmmiddledown
}
92 \member{bool
}{m
\_middleDown}
94 true if the middle mouse button is currently pressed down.
97 \membersection{wxMouseEvent::m
\_rightDown}\label{wxmouseeventmrightdown
}
99 \member{bool
}{m
\_rightDown}
101 true if the right mouse button is currently pressed down.
104 \membersection{wxMouseEvent::m
\_metaDown}\label{wxmouseeventmmetadown
}
106 \member{bool
}{m
\_metaDown}
108 true if the Meta key is pressed down.
111 \membersection{wxMouseEvent::m
\_shiftDown}\label{wxmouseeventmshiftdown
}
113 \member{bool
}{m
\_shiftDown}
115 true if shift is pressed down.
118 \membersection{wxMouseEvent::m
\_x}\label{wxmouseeventmx
}
122 X-coordinate of the event.
125 \membersection{wxMouseEvent::m
\_y}\label{wxmouseeventmy
}
129 Y-coordinate of the event.
132 \membersection{wxMouseEvent::m
\_wheelRotation}\label{wxmouseeventmwheelrotation
}
134 \member{int
}{m
\_wheelRotation}
136 The distance the mouse wheel is rotated.
139 \membersection{wxMouseEvent::m
\_wheelDelta}\label{wxmouseeventmwheeldelta
}
141 \member{int
}{m
\_wheelDelta}
143 The wheel delta, normally $
120$.
146 \membersection{wxMouseEvent::m
\_linesPerAction}\label{wxmouseeventmlinesperaction
}
148 \member{int
}{m
\_linesPerAction}
150 The configured number of lines (or whatever) to be scrolled per wheel
155 \membersection{wxMouseEvent::wxMouseEvent
}\label{wxmouseeventctor
}
157 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0}}
159 Constructor. Valid event types are:
163 \item {\bf wxEVT
\_ENTER\_WINDOW}
164 \item {\bf wxEVT
\_LEAVE\_WINDOW}
165 \item {\bf wxEVT
\_LEFT\_DOWN}
166 \item {\bf wxEVT
\_LEFT\_UP}
167 \item {\bf wxEVT
\_LEFT\_DCLICK}
168 \item {\bf wxEVT
\_MIDDLE\_DOWN}
169 \item {\bf wxEVT
\_MIDDLE\_UP}
170 \item {\bf wxEVT
\_MIDDLE\_DCLICK}
171 \item {\bf wxEVT
\_RIGHT\_DOWN}
172 \item {\bf wxEVT
\_RIGHT\_UP}
173 \item {\bf wxEVT
\_RIGHT\_DCLICK}
174 \item {\bf wxEVT
\_MOTION}
175 \item {\bf wxEVT
\_MOUSEWHEEL}
179 \membersection{wxMouseEvent::AltDown
}\label{wxmouseeventaltdown
}
181 \func{bool
}{AltDown
}{\void}
183 Returns true if the Alt key was down at the time of the event.
186 \membersection{wxMouseEvent::Button
}\label{wxmouseeventbutton
}
188 \func{bool
}{Button
}{\param{int
}{ button
}}
190 Returns true if the identified mouse button is changing state. Valid
191 values of
{\it button
} are:
193 \begin{twocollist
}\itemsep=
0pt
194 \twocolitem{{\tt wxMOUSE
\_BTN\_LEFT}}{check if left button was pressed
}
195 \twocolitem{{\tt wxMOUSE
\_BTN\_MIDDLE}}{check if middle button was pressed
}
196 \twocolitem{{\tt wxMOUSE
\_BTN\_RIGHT}}{check if right button was pressed
}
197 \twocolitem{{\tt wxMOUSE
\_BTN\_ANY}}{check if any button was pressed
}
201 \membersection{wxMouseEvent::ButtonDClick
}\label{wxmouseeventbuttondclick
}
203 \func{bool
}{ButtonDClick
}{\param{int
}{ but = wxMOUSE
\_BTN\_ANY}}
205 If the argument is omitted, this returns true if the event was a mouse
206 double click event. Otherwise the argument specifies which double click event
207 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
211 \membersection{wxMouseEvent::ButtonDown
}\label{wxmouseeventbuttondown
}
213 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
215 If the argument is omitted, this returns true if the event was a mouse
216 button down event. Otherwise the argument specifies which button-down event
217 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
222 \membersection{wxMouseEvent::ButtonUp
}\label{wxmouseeventbuttonup
}
224 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
226 If the argument is omitted, this returns true if the event was a mouse
227 button up event. Otherwise the argument specifies which button-up event
228 was generated (see
\helpref{Button
}{wxmouseeventbutton
} for the possible
233 \membersection{wxMouseEvent::CmdDown
}\label{wxmouseeventcmddown
}
235 \constfunc{bool
}{CmdDown
}{\void}
237 Same as
\helpref{MetaDown
}{wxmouseeventmetadown
} under Mac, same as
238 \helpref{ControlDown
}{wxmouseeventcontroldown
} elsewhere.
242 \helpref{wxKeyEvent::CmdDown
}{wxkeyeventcmddown
}
245 \membersection{wxMouseEvent::ControlDown
}\label{wxmouseeventcontroldown
}
247 \func{bool
}{ControlDown
}{\void}
249 Returns true if the control key was down at the time of the event.
252 \membersection{wxMouseEvent::Dragging
}\label{wxmouseeventdragging
}
254 \func{bool
}{Dragging
}{\void}
256 Returns true if this was a dragging event (motion while a button is depressed).
260 \helpref{Moving
}{wxmouseeventmoving
}
263 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
265 \func{bool
}{Entering
}{\void}
267 Returns true if the mouse was entering the window.
269 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
272 \membersection{wxMouseEvent::GetButton
}\label{wxmouseeventgetbutton
}
274 \constfunc{int
}{GetButton
}{\void}
276 Returns the mouse button which generated this event or
{\tt wxMOUSE
\_BTN\_NONE}
277 if no button is involved (for mouse move, enter or leave event, for example).
278 Otherwise
{\tt wxMOUSE
\_BTN\_LEFT} is returned for the left button down, up and
279 double click events,
{\tt wxMOUSE
\_BTN\_MIDDLE} and
{\tt wxMOUSE
\_BTN\_RIGHT}
280 for the same events for the middle and the right buttons respectively.
283 \membersection{wxMouseEvent::GetPosition
}\label{wxmouseeventgetposition
}
285 \constfunc{wxPoint
}{GetPosition
}{\void}
287 \constfunc{void
}{GetPosition
}{\param{wxCoord*
}{ x
},
\param{wxCoord*
}{ y
}}
289 \constfunc{void
}{GetPosition
}{\param{long*
}{ x
},
\param{long*
}{ y
}}
291 Sets *x and *y to the position at which the event occurred.
293 Returns the physical mouse position in pixels.
295 Note that if the mouse event has been artificially generated from a special
296 keyboard combination (e.g. under Windows when the ``menu'' key is pressed), the
297 returned position is
\texttt{wxDefaultPosition
}.
300 \membersection{wxMouseEvent::GetLogicalPosition
}\label{wxmouseeventgetlogicalposition
}
302 \constfunc{wxPoint
}{GetLogicalPosition
}{\param{const wxDC\&
}{ dc
}}
304 Returns the logical mouse position in pixels (i.e. translated according to the
305 translation set for the DC, which usually indicates that the window has been scrolled).
309 \membersection{wxMouseEvent::GetLinesPerAction
}\label{wxmouseeventgetlinesperaction
}
311 \constfunc{int
}{GetLinesPerAction
}{\void}
313 Returns the configured number of lines (or whatever) to be scrolled per
314 wheel action. Defaults to three.
317 \membersection{wxMouseEvent::GetWheelRotation
}\label{wxmouseeventgetwheelrotation
}
319 \constfunc{int
}{GetWheelRotation
}{\void}
321 Get wheel rotation, positive or negative indicates direction of
322 rotation. Current devices all send an event when rotation is at least
323 +/-WheelDelta, but finer resolution devices can be created in the future.
324 Because of this you shouldn't assume that one event is equal to
1 line, but you
325 should be able to either do partial line scrolling or wait until several
326 events accumulate before scrolling.
329 \membersection{wxMouseEvent::GetWheelDelta
}\label{wxmouseeventgetwheeldelta
}
331 \constfunc{int
}{GetWheelDelta
}{\void}
333 Get wheel delta, normally $
120$. This is the threshold for action to be
334 taken, and one such action (for example, scrolling one increment)
335 should occur for each delta.
338 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
340 \constfunc{long
}{GetX
}{\void}
342 Returns X coordinate of the physical mouse event position.
345 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
347 \func{long
}{GetY
}{\void}
349 Returns Y coordinate of the physical mouse event position.
352 \membersection{wxMouseEvent::IsButton
}\label{wxmouseeventisbutton
}
354 \constfunc{bool
}{IsButton
}{\void}
356 Returns true if the event was a mouse button event (not necessarily a button down event -
357 that may be tested using
{\it ButtonDown
}).
360 \membersection{wxMouseEvent::IsPageScroll
}\label{wxmouseeventispagescroll
}
362 \constfunc{bool
}{IsPageScroll
}{\void}
364 Returns true if the system has been setup to do page scrolling with
365 the mouse wheel instead of line scrolling.
368 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
370 \constfunc{bool
}{Leaving
}{\void}
372 Returns true if the mouse was leaving the window.
374 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
377 \membersection{wxMouseEvent::LeftDClick
}\label{wxmouseeventleftdclick
}
379 \constfunc{bool
}{LeftDClick
}{\void}
381 Returns true if the event was a left double click.
384 \membersection{wxMouseEvent::LeftDown
}\label{wxmouseeventleftdown
}
386 \constfunc{bool
}{LeftDown
}{\void}
388 Returns true if the left mouse button changed to down.
391 \membersection{wxMouseEvent::LeftIsDown
}\label{wxmouseeventleftisdown
}
393 \constfunc{bool
}{LeftIsDown
}{\void}
395 Returns true if the left mouse button is currently down, independent
396 of the current event type.
398 Please notice that it is
\emph{not
} the same as
399 \helpref{LeftDown
}{wxmouseeventleftdown
} which returns
\true if the event was
400 generated by the left mouse button being pressed. Rather, it simply describes
401 the state of the left mouse button at the time when the event was generated
402 (so while it will be true for a left click event, it can also be true for
403 a right click if it happened while the left mouse button was pressed).
405 This event is usually used in the mouse event handlers which process "move
406 mouse" messages to determine whether the user is (still) dragging the mouse.
409 \membersection{wxMouseEvent::LeftUp
}\label{wxmouseeventleftup
}
411 \constfunc{bool
}{LeftUp
}{\void}
413 Returns true if the left mouse button changed to up.
416 \membersection{wxMouseEvent::MetaDown
}\label{wxmouseeventmetadown
}
418 \constfunc{bool
}{MetaDown
}{\void}
420 Returns true if the Meta key was down at the time of the event.
423 \membersection{wxMouseEvent::MiddleDClick
}\label{wxmouseeventmiddledclick
}
425 \constfunc{bool
}{MiddleDClick
}{\void}
427 Returns true if the event was a middle double click.
430 \membersection{wxMouseEvent::MiddleDown
}\label{wxmouseeventmiddledown
}
432 \constfunc{bool
}{MiddleDown
}{\void}
434 Returns true if the middle mouse button changed to down.
437 \membersection{wxMouseEvent::MiddleIsDown
}\label{wxmouseeventmiddleisdown
}
439 \constfunc{bool
}{MiddleIsDown
}{\void}
441 Returns true if the middle mouse button is currently down, independent
442 of the current event type.
445 \membersection{wxMouseEvent::MiddleUp
}\label{wxmouseeventmiddleup
}
447 \constfunc{bool
}{MiddleUp
}{\void}
449 Returns true if the middle mouse button changed to up.
452 \membersection{wxMouseEvent::Moving
}\label{wxmouseeventmoving
}
454 \constfunc{bool
}{Moving
}{\void}
456 Returns true if this was a motion event and no mouse buttons were pressed.
457 If any mouse button is held pressed, then this method returns
\false and
458 \helpref{Dragging
}{wxmouseeventdragging
} returns
\true.
461 \membersection{wxMouseEvent::RightDClick
}\label{wxmouseeventrightdclick
}
463 \constfunc{bool
}{RightDClick
}{\void}
465 Returns true if the event was a right double click.
468 \membersection{wxMouseEvent::RightDown
}\label{wxmouseeventrightdown
}
470 \constfunc{bool
}{RightDown
}{\void}
472 Returns true if the right mouse button changed to down.
475 \membersection{wxMouseEvent::RightIsDown
}\label{wxmouseeventrightisdown
}
477 \constfunc{bool
}{RightIsDown
}{\void}
479 Returns true if the right mouse button is currently down, independent
480 of the current event type.
483 \membersection{wxMouseEvent::RightUp
}\label{wxmouseeventrightup
}
485 \constfunc{bool
}{RightUp
}{\void}
487 Returns true if the right mouse button changed to up.
490 \membersection{wxMouseEvent::ShiftDown
}\label{wxmouseeventshiftdown
}
492 \constfunc{bool
}{ShiftDown
}{\void}
494 Returns true if the shift key was down at the time of the event.