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 $
1$ for the left mouse button, $
2$
7 for the middle one and $
3$ for the right one. Note that not all mice have
8 a middle button so a portable application should avoid relying on the events
11 {\bf NB:
} Note that under Windows mouse enter and leave events are not natively supported
12 by the system but are generated by wxWindows itself. This has several
13 drawbacks: the LEAVE
\_WINDOW event might be received some time after the mouse
14 left the window and the state variables for it may have changed during this
17 {\bf NB:
} Note the difference between methods like
18 \helpref{LeftDown
}{wxmouseeventleftdown
} and
19 \helpref{LeftIsDown
}{wxmouseeventleftisdown
}: the formet returns
{\tt TRUE
}
20 when the event corresponds to the left mouse button click while the latter
21 returns
{\tt TRUE
} if the left mouse button is currently being pressed. For
22 example, when the user is dragging the mouse you can use
23 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} to test
24 whether the left mouse button is (still) depressed. Also, by convention, if
25 \helpref{LeftDown
}{wxmouseeventleftdown
} returns
{\tt TRUE
},
26 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} will also return
{\tt TRUE
} in
27 wxWindows whatever the underlying GUI behaviour is (which is
28 platform-dependent). The same applies, of course, to other mouse buttons as
31 \wxheading{Derived from
}
33 \helpref{wxEvent
}{wxevent
}
35 \wxheading{Include files
}
39 \wxheading{Event table macros
}
41 To process a mouse event, use these event handler macros to direct input to member
42 functions that take a wxMouseEvent argument.
45 \begin{twocollist
}\itemsep=
0pt
46 \twocolitem{{\bf EVT
\_LEFT\_DOWN(func)
}}{Process a wxEVT
\_LEFT\_DOWN event.
}
47 \twocolitem{{\bf EVT
\_LEFT\_UP(func)
}}{Process a wxEVT
\_LEFT\_UP event.
}
48 \twocolitem{{\bf EVT
\_LEFT\_DCLICK(func)
}}{Process a wxEVT
\_LEFT\_DCLICK event.
}
49 \twocolitem{{\bf EVT
\_MIDDLE\_DOWN(func)
}}{Process a wxEVT
\_MIDDLE\_DOWN event.
}
50 \twocolitem{{\bf EVT
\_MIDDLE\_UP(func)
}}{Process a wxEVT
\_MIDDLE\_UP event.
}
51 \twocolitem{{\bf EVT
\_MIDDLE\_DCLICK(func)
}}{Process a wxEVT
\_MIDDLE\_DCLICK event.
}
52 \twocolitem{{\bf EVT
\_RIGHT\_DOWN(func)
}}{Process a wxEVT
\_RIGHT\_DOWN event.
}
53 \twocolitem{{\bf EVT
\_RIGHT\_UP(func)
}}{Process a wxEVT
\_RIGHT\_UP event.
}
54 \twocolitem{{\bf EVT
\_RIGHT\_DCLICK(func)
}}{Process a wxEVT
\_RIGHT\_DCLICK event.
}
55 \twocolitem{{\bf EVT
\_MOTION(func)
}}{Process a wxEVT
\_MOTION event.
}
56 \twocolitem{{\bf EVT
\_ENTER\_WINDOW(func)
}}{Process a wxEVT
\_ENTER\_WINDOW event.
}
57 \twocolitem{{\bf EVT
\_LEAVE\_WINDOW(func)
}}{Process a wxEVT
\_LEAVE\_WINDOW event.
}
58 \twocolitem{{\bf EVT
\_MOUSEWHEEL(func)
}}{Process a wxEVT
\_MOUSEWHEEL event.
}
59 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
62 \latexignore{\rtfignore{\wxheading{Members
}}}
64 \membersection{wxMouseEvent::m
\_altDown}
66 \member{bool
}{m
\_altDown}
68 TRUE if the Alt key is pressed down.
70 \membersection{wxMouseEvent::m
\_controlDown}
72 \member{bool
}{m
\_controlDown}
74 TRUE if control key is pressed down.
76 \membersection{wxMouseEvent::m
\_leftDown}
78 \member{bool
}{m
\_leftDown}
80 TRUE if the left mouse button is currently pressed down.
82 \membersection{wxMouseEvent::m
\_middleDown}
84 \member{bool
}{m
\_middleDown}
86 TRUE if the middle mouse button is currently pressed down.
88 \membersection{wxMouseEvent::m
\_rightDown}
90 \member{bool
}{m
\_rightDown}
92 TRUE if the right mouse button is currently pressed down.
94 \membersection{wxMouseEvent::m
\_metaDown}
96 \member{bool
}{m
\_metaDown}
98 TRUE if the Meta key is pressed down.
100 \membersection{wxMouseEvent::m
\_shiftDown}
102 \member{bool
}{m
\_shiftDown}
104 TRUE if shift is pressed down.
106 \membersection{wxMouseEvent::m
\_x}
110 X-coordinate of the event.
112 \membersection{wxMouseEvent::m
\_y}
116 Y-coordinate of the event.
118 \membersection{wxMouseEvent::m
\_wheelRotation}
120 \member{int
}{m
\_wheelRotation}
122 The distance the mouse wheel is rotated.
124 \membersection{wxMouseEvent::m
\_wheelDelta}
126 \member{int
}{m
\_wheelDelta}
128 The wheel delta, normally
120.
130 \membersection{wxMouseEvent::m
\_linesPerAction}
132 \member{int
}{m
\_linesPerAction}
134 The configured number of lines (or whatever) to be scrolled per wheel
138 \membersection{wxMouseEvent::wxMouseEvent
}
140 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0},
\param{int
}{ id =
0}}
142 Constructor. Valid event types are:
146 \item {\bf wxEVT
\_ENTER\_WINDOW}
147 \item {\bf wxEVT
\_LEAVE\_WINDOW}
148 \item {\bf wxEVT
\_LEFT\_DOWN}
149 \item {\bf wxEVT
\_LEFT\_UP}
150 \item {\bf wxEVT
\_LEFT\_DCLICK}
151 \item {\bf wxEVT
\_MIDDLE\_DOWN}
152 \item {\bf wxEVT
\_MIDDLE\_UP}
153 \item {\bf wxEVT
\_MIDDLE\_DCLICK}
154 \item {\bf wxEVT
\_RIGHT\_DOWN}
155 \item {\bf wxEVT
\_RIGHT\_UP}
156 \item {\bf wxEVT
\_RIGHT\_DCLICK}
157 \item {\bf wxEVT
\_MOTION}
158 \item {\bf wxEVT
\_MOUSEWHEEL}
161 \membersection{wxMouseEvent::AltDown
}
163 \func{bool
}{AltDown
}{\void}
165 Returns TRUE if the Alt key was down at the time of the event.
167 \membersection{wxMouseEvent::Button
}
169 \func{bool
}{Button
}{\param{int
}{ button
}}
171 Returns TRUE if the identified mouse button is changing state. Valid
172 values of
{\it button
} are
1,
2 or
3 for left, middle and right
173 buttons respectively.
175 \membersection{wxMouseEvent::ButtonDClick
}\label{buttondclick
}
177 \func{bool
}{ButtonDClick
}{\param{int
}{ but = -
1}}
179 If the argument is omitted, this returns TRUE if the event was a mouse
180 double click event. Otherwise the argument specifies which double click event
181 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
183 \membersection{wxMouseEvent::ButtonDown
}
185 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
187 If the argument is omitted, this returns TRUE if the event was a mouse
188 button down event. Otherwise the argument specifies which button-down event
189 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
191 \membersection{wxMouseEvent::ButtonUp
}
193 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
195 If the argument is omitted, this returns TRUE if the event was a mouse
196 button up event. Otherwise the argument specifies which button-up event
197 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
199 \membersection{wxMouseEvent::ControlDown
}
201 \func{bool
}{ControlDown
}{\void}
203 Returns TRUE if the control key was down at the time of the event.
205 \membersection{wxMouseEvent::Dragging
}
207 \func{bool
}{Dragging
}{\void}
209 Returns TRUE if this was a dragging event (motion while a button is depressed).
211 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
213 \func{bool
}{Entering
}{\void}
215 Returns TRUE if the mouse was entering the window.
217 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
219 \membersection{wxMouseEvent::GetButton
}\label{wxmouseeventgetbutton
}
221 \constfunc{int
}{GetButton
}{\void}
223 Returns the mouse button which generated this event or $-
1$ if no button is
224 involved (for mouse move, enter or leave event, for example). The value $
1$ is
225 returned for the left button down, up and double click events, $
2$ and $
3$ for
226 the same events for the middle and the right buttons respectively.
228 \membersection{wxMouseEvent::GetPosition
}\label{wxmouseeventgetposition
}
230 \constfunc{wxPoint
}{GetPosition
}{\void}
232 \constfunc{void
}{GetPosition
}{\param{wxCoord*
}{ x
},
\param{wxCoord*
}{ y
}}
234 \constfunc{void
}{GetPosition
}{\param{long*
}{ x
},
\param{long*
}{ y
}}
236 Sets *x and *y to the position at which the event occurred.
238 Returns the physical mouse position in pixels.
240 \membersection{wxMouseEvent::GetLogicalPosition
}\label{wxmouseeventgetlogicalposition
}
242 \constfunc{wxPoint
}{GetLogicalPosition
}{\param{const wxDC\&
}{ dc
}}
244 Returns the logical mouse position in pixels (i.e. translated according to the
245 translation set for the DC, which usually indicates that the window has been scrolled).
248 \membersection{wxMouseEvent::GetLinesPerAction
}\label{wxmouseeventgetlinesperaction
}
250 \constfunc{int
}{GetLinesPerAction
}{\void}
252 Returns the configured number of lines (or whatever) to be scrolled per
253 wheel action. Defaults to three.
255 \membersection{wxMouseEvent::GetWheelRotation
}\label{wxmouseeventgetwheelrotation
}
257 \constfunc{int
}{GetWheelRotation
}{\void}
259 Get wheel rotation, positive or negative indicates direction of
260 rotation. Current devices all send an event when rotation is equal to
261 +/-WheelDelta, but this allows for finer resolution devices to be
262 created in the future. Because of this you shouldn't assume that one
263 event is equal to
1 line or whatever, but you should be able to either
264 do partial line scrolling or wait until +/-WheelDelta rotation values
265 have been accumulated before scrolling.
267 \membersection{wxMouseEvent::GetWheelDelta
}\label{wxmouseeventgetwheeldelta
}
269 \constfunc{int
}{GetWheelDelta
}{\void}
271 Get wheel delta, normally
120. This is the threshold for action to be
272 taken, and one such action (for example, scrolling one increment)
273 should occur for each delta.
275 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
277 \constfunc{long
}{GetX
}{\void}
279 Returns X coordinate of the physical mouse event position.
281 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
283 \func{long
}{GetY
}{\void}
285 Returns Y coordinate of the physical mouse event position.
287 \membersection{wxMouseEvent::IsButton
}
289 \constfunc{bool
}{IsButton
}{\void}
291 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
292 that may be tested using
{\it ButtonDown
}).
294 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
296 \constfunc{bool
}{Leaving
}{\void}
298 Returns TRUE if the mouse was leaving the window.
300 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
302 \membersection{wxMouseEvent::LeftDClick
}
304 \constfunc{bool
}{LeftDClick
}{\void}
306 Returns TRUE if the event was a left double click.
308 \membersection{wxMouseEvent::LeftDown
}\label{wxmouseeventleftdown
}
310 \constfunc{bool
}{LeftDown
}{\void}
312 Returns TRUE if the left mouse button changed to down.
314 \membersection{wxMouseEvent::LeftIsDown
}\label{wxmouseeventleftisdown
}
316 \constfunc{bool
}{LeftIsDown
}{\void}
318 Returns TRUE if the left mouse button is currently down, independent
319 of the current event type.
321 Please notice that it is
{\bf not
} the same as
322 \helpref{LeftDown
}{wxmouseeventleftdown
} which returns TRUE if the left mouse
323 button was just pressed. Rather, it describes the state of the mouse button
324 before the event happened.
326 This event is usually used in the mouse event handlers which process "move
327 mouse" messages to determine whether the user is (still) dragging the mouse.
329 \membersection{wxMouseEvent::LeftUp
}
331 \constfunc{bool
}{LeftUp
}{\void}
333 Returns TRUE if the left mouse button changed to up.
335 \membersection{wxMouseEvent::MetaDown
}
337 \constfunc{bool
}{MetaDown
}{\void}
339 Returns TRUE if the Meta key was down at the time of the event.
341 \membersection{wxMouseEvent::MiddleDClick
}
343 \constfunc{bool
}{MiddleDClick
}{\void}
345 Returns TRUE if the event was a middle double click.
347 \membersection{wxMouseEvent::MiddleDown
}
349 \constfunc{bool
}{MiddleDown
}{\void}
351 Returns TRUE if the middle mouse button changed to down.
353 \membersection{wxMouseEvent::MiddleIsDown
}\label{wxmouseeventmiddleisdown
}
355 \constfunc{bool
}{MiddleIsDown
}{\void}
357 Returns TRUE if the middle mouse button is currently down, independent
358 of the current event type.
360 \membersection{wxMouseEvent::MiddleUp
}
362 \constfunc{bool
}{MiddleUp
}{\void}
364 Returns TRUE if the middle mouse button changed to up.
366 \membersection{wxMouseEvent::Moving
}
368 \constfunc{bool
}{Moving
}{\void}
370 Returns TRUE if this was a motion event (no buttons depressed).
372 \membersection{wxMouseEvent::RightDClick
}
374 \constfunc{bool
}{RightDClick
}{\void}
376 Returns TRUE if the event was a right double click.
378 \membersection{wxMouseEvent::RightDown
}
380 \constfunc{bool
}{RightDown
}{\void}
382 Returns TRUE if the right mouse button changed to down.
384 \membersection{wxMouseEvent::RightIsDown
}\label{wxmouseeventrightisdown
}
386 \constfunc{bool
}{RightIsDown
}{\void}
388 Returns TRUE if the right mouse button is currently down, independent
389 of the current event type.
391 \membersection{wxMouseEvent::RightUp
}
393 \constfunc{bool
}{RightUp
}{\void}
395 Returns TRUE if the right mouse button changed to up.
397 \membersection{wxMouseEvent::ShiftDown
}
399 \constfunc{bool
}{ShiftDown
}{\void}
401 Returns TRUE if the shift key was down at the time of the event.