]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mouseevt.tex
explain that wxRTTI macros must be used for OnCompareItems() to be called
[wxWidgets.git] / docs / latex / wx / mouseevt.tex
CommitLineData
a660d684
KB
1\section{\class{wxMouseEvent}}\label{wxmouseevent}
2
ec760ec9
VZ
3This event class contains information about the events generated by the mouse:
4they include mouse buttons press and release events and mouse move events.
5
8e7cd32b
VZ
6All mouse events involving the buttons use {\tt wxMOUSE\_BTN\_LEFT} for the
7left 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
9middle button so a portable application should avoid relying on the events from
10it.
a660d684 11
faa97247 12{\bf NB:} Note that under Windows CE mouse enter and leave events are not natively supported
fc2171bd 13by the system but are generated by wxWidgets itself. This has several
4aff28fc
VZ
14drawbacks: the LEAVE\_WINDOW event might be received some time after the mouse
15left the window and the state variables for it may have changed during this
16time.
17
9b9337da
RD
18{\bf NB:} Note the difference between methods like
19\helpref{LeftDown}{wxmouseeventleftdown} and
cc81d32f 20\helpref{LeftIsDown}{wxmouseeventleftisdown}: the former returns {\tt true}
f6bcfd97 21when the event corresponds to the left mouse button click while the latter
cc81d32f 22returns {\tt true} if the left mouse button is currently being pressed. For
9b9337da 23example, when the user is dragging the mouse you can use
f6bcfd97
BP
24\helpref{LeftIsDown}{wxmouseeventleftisdown} to test
25whether the left mouse button is (still) depressed. Also, by convention, if
cc81d32f
VS
26\helpref{LeftDown}{wxmouseeventleftdown} returns {\tt true},
27\helpref{LeftIsDown}{wxmouseeventleftisdown} will also return {\tt true} in
fc2171bd 28wxWidgets whatever the underlying GUI behaviour is (which is
f6bcfd97
BP
29platform-dependent). The same applies, of course, to other mouse buttons as
30well.
31
a660d684
KB
32\wxheading{Derived from}
33
34\helpref{wxEvent}{wxevent}
35
954b8ae6
JS
36\wxheading{Include files}
37
38<wx/event.h>
39
a660d684
KB
40\wxheading{Event table macros}
41
42To process a mouse event, use these event handler macros to direct input to member
43functions that take a wxMouseEvent argument.
44
45\twocolwidtha{7cm}
46\begin{twocollist}\itemsep=0pt
58dee211
VZ
47\twocolitem{{\bf EVT\_LEFT\_DOWN(func)}}{Process a wxEVT\_LEFT\_DOWN event. The
48handler of this event should normally call \helpref{event.Skip()}{wxeventskip} to
49allow the default processing to take place as otherwise the window under mouse
50wouldn't get the focus.}
a660d684
KB
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.}
d2c52078 62\twocolitem{{\bf EVT\_MOUSEWHEEL(func)}}{Process a wxEVT\_MOUSEWHEEL event.}
5de76427 63\twocolitem{{\bf EVT\_MOUSE\_EVENTS(func)}}{Process all mouse events.}
a660d684
KB
64\end{twocollist}%
65
66\latexignore{\rtfignore{\wxheading{Members}}}
67
6f63704f 68
3e79fa75 69\membersection{wxMouseEvent::m\_altDown}\label{wxmouseeventmaltdown}
a660d684
KB
70
71\member{bool}{m\_altDown}
72
cc81d32f 73true if the Alt key is pressed down.
a660d684 74
6f63704f 75
3e79fa75 76\membersection{wxMouseEvent::m\_controlDown}\label{wxmouseeventmcontroldown}
a660d684
KB
77
78\member{bool}{m\_controlDown}
79
cc81d32f 80true if control key is pressed down.
a660d684 81
6f63704f 82
3e79fa75 83\membersection{wxMouseEvent::m\_leftDown}\label{wxmouseeventmleftdown}
a660d684
KB
84
85\member{bool}{m\_leftDown}
86
cc81d32f 87true if the left mouse button is currently pressed down.
a660d684 88
6f63704f 89
3e79fa75 90\membersection{wxMouseEvent::m\_middleDown}\label{wxmouseeventmmiddledown}
a660d684
KB
91
92\member{bool}{m\_middleDown}
93
cc81d32f 94true if the middle mouse button is currently pressed down.
a660d684 95
6f63704f 96
3e79fa75 97\membersection{wxMouseEvent::m\_rightDown}\label{wxmouseeventmrightdown}
a660d684
KB
98
99\member{bool}{m\_rightDown}
100
cc81d32f 101true if the right mouse button is currently pressed down.
a660d684 102
6f63704f 103
3e79fa75 104\membersection{wxMouseEvent::m\_metaDown}\label{wxmouseeventmmetadown}
a660d684
KB
105
106\member{bool}{m\_metaDown}
107
cc81d32f 108true if the Meta key is pressed down.
a660d684 109
6f63704f 110
3e79fa75 111\membersection{wxMouseEvent::m\_shiftDown}\label{wxmouseeventmshiftdown}
a660d684
KB
112
113\member{bool}{m\_shiftDown}
114
cc81d32f 115true if shift is pressed down.
a660d684 116
6f63704f 117
3e79fa75 118\membersection{wxMouseEvent::m\_x}\label{wxmouseeventmx}
a660d684 119
803ef874 120\member{long}{m\_x}
a660d684
KB
121
122X-coordinate of the event.
123
6f63704f 124
3e79fa75 125\membersection{wxMouseEvent::m\_y}\label{wxmouseeventmy}
a660d684 126
803ef874 127\member{long}{m\_y}
a660d684
KB
128
129Y-coordinate of the event.
130
6f63704f 131
3e79fa75 132\membersection{wxMouseEvent::m\_wheelRotation}\label{wxmouseeventmwheelrotation}
d2c52078
RD
133
134\member{int}{m\_wheelRotation}
135
136The distance the mouse wheel is rotated.
137
6f63704f 138
3e79fa75 139\membersection{wxMouseEvent::m\_wheelDelta}\label{wxmouseeventmwheeldelta}
d2c52078
RD
140
141\member{int}{m\_wheelDelta}
142
8e7cd32b 143The wheel delta, normally $120$.
d2c52078 144
6f63704f 145
3e79fa75 146\membersection{wxMouseEvent::m\_linesPerAction}\label{wxmouseeventmlinesperaction}
d2c52078
RD
147
148\member{int}{m\_linesPerAction}
149
150The configured number of lines (or whatever) to be scrolled per wheel
151action.
152
153
6f63704f 154
3e79fa75 155\membersection{wxMouseEvent::wxMouseEvent}\label{wxmouseeventctor}
a660d684 156
f6e9a818 157\func{}{wxMouseEvent}{\param{WXTYPE}{ mouseEventType = 0}}
a660d684
KB
158
159Constructor. Valid event types are:
160
161\begin{itemize}
162\itemsep=0pt
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}
d2c52078 175\item {\bf wxEVT\_MOUSEWHEEL}
a660d684
KB
176\end{itemize}
177
6f63704f 178
3e79fa75 179\membersection{wxMouseEvent::AltDown}\label{wxmouseeventaltdown}
a660d684
KB
180
181\func{bool}{AltDown}{\void}
182
cc81d32f 183Returns true if the Alt key was down at the time of the event.
a660d684 184
6f63704f 185
8e7cd32b 186\membersection{wxMouseEvent::Button}\label{wxmouseeventbutton}
a660d684
KB
187
188\func{bool}{Button}{\param{int}{ button}}
189
cc81d32f 190Returns true if the identified mouse button is changing state. Valid
8e7cd32b 191values of {\it button} are:
a660d684 192
8e7cd32b 193\begin{twocollist}\itemsep=0pt
91fd135b 194\twocolitem{{\tt wxMOUSE\_BTN\_LEFT}}{check if left button was pressed}
dbd94b75
KH
195\twocolitem{{\tt wxMOUSE\_BTN\_MIDDLE}}{check if middle button was pressed}
196\twocolitem{{\tt wxMOUSE\_BTN\_RIGHT}}{check if right button was pressed}
91fd135b 197\twocolitem{{\tt wxMOUSE\_BTN\_ANY}}{check if any button was pressed}
8e7cd32b
VZ
198\end{twocollist}
199
6f63704f 200
3e79fa75 201\membersection{wxMouseEvent::ButtonDClick}\label{wxmouseeventbuttondclick}
a660d684 202
8e7cd32b 203\func{bool}{ButtonDClick}{\param{int}{ but = wxMOUSE\_BTN\_ANY}}
a660d684 204
cc81d32f 205If the argument is omitted, this returns true if the event was a mouse
a660d684 206double click event. Otherwise the argument specifies which double click event
8e7cd32b
VZ
207was generated (see \helpref{Button}{wxmouseeventbutton} for the possible
208values).
a660d684 209
6f63704f 210
3e79fa75 211\membersection{wxMouseEvent::ButtonDown}\label{wxmouseeventbuttondown}
a660d684
KB
212
213\func{bool}{ButtonDown}{\param{int}{ but = -1}}
214
cc81d32f 215If the argument is omitted, this returns true if the event was a mouse
a660d684 216button down event. Otherwise the argument specifies which button-down event
8e7cd32b
VZ
217was generated (see \helpref{Button}{wxmouseeventbutton} for the possible
218values).
219
a660d684 220
6f63704f 221
3e79fa75 222\membersection{wxMouseEvent::ButtonUp}\label{wxmouseeventbuttonup}
a660d684
KB
223
224\func{bool}{ButtonUp}{\param{int}{ but = -1}}
225
cc81d32f 226If the argument is omitted, this returns true if the event was a mouse
a660d684 227button up event. Otherwise the argument specifies which button-up event
8e7cd32b
VZ
228was generated (see \helpref{Button}{wxmouseeventbutton} for the possible
229values).
230
a660d684 231
6f63704f 232
9cc73180 233\membersection{wxMouseEvent::CmdDown}\label{wxmouseeventcmddown}
a2bd1520
VZ
234
235\constfunc{bool}{CmdDown}{\void}
236
237Same as \helpref{MetaDown}{wxmouseeventmetadown} under Mac, same as
238\helpref{ControlDown}{wxmouseeventcontroldown} elsewhere.
239
240\wxheading{See also}
241
dc66ae68 242\helpref{wxKeyEvent::CmdDown}{wxkeyeventcmddown}
a2bd1520
VZ
243
244
245\membersection{wxMouseEvent::ControlDown}\label{wxmouseeventcontroldown}
a660d684
KB
246
247\func{bool}{ControlDown}{\void}
248
cc81d32f 249Returns true if the control key was down at the time of the event.
a660d684 250
6f63704f 251
100cf085 252\membersection{wxMouseEvent::Dragging}\label{wxmouseeventdragging}
a660d684
KB
253
254\func{bool}{Dragging}{\void}
255
cc81d32f 256Returns true if this was a dragging event (motion while a button is depressed).
a660d684 257
100cf085
VZ
258\wxheading{See also}
259
260\helpref{Moving}{wxmouseeventmoving}
261
6f63704f 262
a660d684
KB
263\membersection{wxMouseEvent::Entering}\label{wxmouseevententering}
264
265\func{bool}{Entering}{\void}
266
cc81d32f 267Returns true if the mouse was entering the window.
a660d684
KB
268
269See also \helpref{wxMouseEvent::Leaving}{wxmouseeventleaving}.
270
6f63704f 271
ec760ec9
VZ
272\membersection{wxMouseEvent::GetButton}\label{wxmouseeventgetbutton}
273
274\constfunc{int}{GetButton}{\void}
275
8e7cd32b
VZ
276Returns the mouse button which generated this event or {\tt wxMOUSE\_BTN\_NONE}
277if no button is involved (for mouse move, enter or leave event, for example).
278Otherwise {\tt wxMOUSE\_BTN\_LEFT} is returned for the left button down, up and
279double click events, {\tt wxMOUSE\_BTN\_MIDDLE} and {\tt wxMOUSE\_BTN\_RIGHT}
280for the same events for the middle and the right buttons respectively.
ec760ec9 281
6f63704f 282
803ef874
JS
283\membersection{wxMouseEvent::GetPosition}\label{wxmouseeventgetposition}
284
285\constfunc{wxPoint}{GetPosition}{\void}
286
fa482912
JS
287\constfunc{void}{GetPosition}{\param{wxCoord*}{ x}, \param{wxCoord*}{ y}}
288
289\constfunc{void}{GetPosition}{\param{long*}{ x}, \param{long*}{ y}}
803ef874
JS
290
291Sets *x and *y to the position at which the event occurred.
292
293Returns the physical mouse position in pixels.
294
ae177b45
VZ
295Note that if the mouse event has been artificially generated from a special
296keyboard combination (e.g. under Windows when the ``menu'' key is pressed), the
297returned position is \texttt{wxDefaultPosition}.
298
6f63704f 299
803ef874
JS
300\membersection{wxMouseEvent::GetLogicalPosition}\label{wxmouseeventgetlogicalposition}
301
302\constfunc{wxPoint}{GetLogicalPosition}{\param{const wxDC\&}{ dc}}
303
304Returns the logical mouse position in pixels (i.e. translated according to the
305translation set for the DC, which usually indicates that the window has been scrolled).
306
d2c52078 307
6f63704f 308
d2c52078
RD
309\membersection{wxMouseEvent::GetLinesPerAction}\label{wxmouseeventgetlinesperaction}
310
311\constfunc{int}{GetLinesPerAction}{\void}
312
313Returns the configured number of lines (or whatever) to be scrolled per
d13d99aa 314wheel action. Defaults to three.
d2c52078 315
6f63704f 316
d2c52078
RD
317\membersection{wxMouseEvent::GetWheelRotation}\label{wxmouseeventgetwheelrotation}
318
319\constfunc{int}{GetWheelRotation}{\void}
320
321Get wheel rotation, positive or negative indicates direction of
9aeb24a0
VZ
322rotation. Current devices all send an event when rotation is at least
323+/-WheelDelta, but finer resolution devices can be created in the future.
324Because of this you shouldn't assume that one event is equal to 1 line, but you
325should be able to either do partial line scrolling or wait until several
326events accumulate before scrolling.
d2c52078 327
6f63704f 328
d2c52078
RD
329\membersection{wxMouseEvent::GetWheelDelta}\label{wxmouseeventgetwheeldelta}
330
331\constfunc{int}{GetWheelDelta}{\void}
332
8e7cd32b 333Get wheel delta, normally $120$. This is the threshold for action to be
d2c52078
RD
334taken, and one such action (for example, scrolling one increment)
335should occur for each delta.
336
6f63704f 337
a660d684
KB
338\membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
339
803ef874 340\constfunc{long}{GetX}{\void}
a660d684 341
803ef874 342Returns X coordinate of the physical mouse event position.
a660d684 343
6f63704f 344
a660d684
KB
345\membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
346
803ef874 347\func{long}{GetY}{\void}
a660d684 348
803ef874 349Returns Y coordinate of the physical mouse event position.
a660d684 350
6f63704f 351
3e79fa75 352\membersection{wxMouseEvent::IsButton}\label{wxmouseeventisbutton}
a660d684 353
803ef874 354\constfunc{bool}{IsButton}{\void}
a660d684 355
cc81d32f 356Returns true if the event was a mouse button event (not necessarily a button down event -
a660d684
KB
357that may be tested using {\it ButtonDown}).
358
6f63704f 359
3e79fa75 360\membersection{wxMouseEvent::IsPageScroll}\label{wxmouseeventispagescroll}
9b9337da
RD
361
362\constfunc{bool}{IsPageScroll}{\void}
363
cc81d32f 364Returns true if the system has been setup to do page scrolling with
9b9337da
RD
365the mouse wheel instead of line scrolling.
366
6f63704f 367
a660d684
KB
368\membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
369
803ef874 370\constfunc{bool}{Leaving}{\void}
a660d684 371
cc81d32f 372Returns true if the mouse was leaving the window.
a660d684
KB
373
374See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
375
6f63704f 376
3e79fa75 377\membersection{wxMouseEvent::LeftDClick}\label{wxmouseeventleftdclick}
a660d684 378
803ef874 379\constfunc{bool}{LeftDClick}{\void}
a660d684 380
cc81d32f 381Returns true if the event was a left double click.
a660d684 382
6f63704f 383
2cdd0d01 384\membersection{wxMouseEvent::LeftDown}\label{wxmouseeventleftdown}
a660d684 385
803ef874 386\constfunc{bool}{LeftDown}{\void}
a660d684 387
cc81d32f 388Returns true if the left mouse button changed to down.
a660d684 389
6f63704f 390
f6bcfd97 391\membersection{wxMouseEvent::LeftIsDown}\label{wxmouseeventleftisdown}
a660d684 392
803ef874 393\constfunc{bool}{LeftIsDown}{\void}
a660d684 394
cc81d32f 395Returns true if the left mouse button is currently down, independent
a660d684
KB
396of the current event type.
397
7430e321
VZ
398Please notice that it is \emph{not} the same as
399\helpref{LeftDown}{wxmouseeventleftdown} which returns \true if the event was
400generated by the left mouse button being pressed. Rather, it simply describes
dad0c6d3
VZ
401the 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
403a right click if it happened while the left mouse button was pressed).
2cdd0d01
VZ
404
405This event is usually used in the mouse event handlers which process "move
406mouse" messages to determine whether the user is (still) dragging the mouse.
407
6f63704f 408
3e79fa75 409\membersection{wxMouseEvent::LeftUp}\label{wxmouseeventleftup}
a660d684 410
803ef874 411\constfunc{bool}{LeftUp}{\void}
a660d684 412
cc81d32f 413Returns true if the left mouse button changed to up.
a660d684 414
6f63704f 415
a2bd1520 416\membersection{wxMouseEvent::MetaDown}\label{wxmouseeventmetadown}
a660d684 417
803ef874 418\constfunc{bool}{MetaDown}{\void}
a660d684 419
cc81d32f 420Returns true if the Meta key was down at the time of the event.
a660d684 421
6f63704f 422
3e79fa75 423\membersection{wxMouseEvent::MiddleDClick}\label{wxmouseeventmiddledclick}
a660d684 424
803ef874 425\constfunc{bool}{MiddleDClick}{\void}
a660d684 426
cc81d32f 427Returns true if the event was a middle double click.
a660d684 428
6f63704f 429
3e79fa75 430\membersection{wxMouseEvent::MiddleDown}\label{wxmouseeventmiddledown}
a660d684 431
803ef874 432\constfunc{bool}{MiddleDown}{\void}
a660d684 433
cc81d32f 434Returns true if the middle mouse button changed to down.
a660d684 435
6f63704f 436
f6bcfd97 437\membersection{wxMouseEvent::MiddleIsDown}\label{wxmouseeventmiddleisdown}
a660d684 438
803ef874 439\constfunc{bool}{MiddleIsDown}{\void}
a660d684 440
cc81d32f 441Returns true if the middle mouse button is currently down, independent
a660d684
KB
442of the current event type.
443
6f63704f 444
3e79fa75 445\membersection{wxMouseEvent::MiddleUp}\label{wxmouseeventmiddleup}
a660d684 446
803ef874 447\constfunc{bool}{MiddleUp}{\void}
a660d684 448
cc81d32f 449Returns true if the middle mouse button changed to up.
a660d684 450
6f63704f 451
100cf085 452\membersection{wxMouseEvent::Moving}\label{wxmouseeventmoving}
a660d684 453
803ef874 454\constfunc{bool}{Moving}{\void}
a660d684 455
6f63704f
VZ
456Returns true if this was a motion event and no mouse buttons were pressed.
457If any mouse button is held pressed, then this method returns \false and
458\helpref{Dragging}{wxmouseeventdragging} returns \true.
459
a660d684 460
3e79fa75 461\membersection{wxMouseEvent::RightDClick}\label{wxmouseeventrightdclick}
a660d684 462
803ef874 463\constfunc{bool}{RightDClick}{\void}
a660d684 464
cc81d32f 465Returns true if the event was a right double click.
a660d684 466
6f63704f 467
3e79fa75 468\membersection{wxMouseEvent::RightDown}\label{wxmouseeventrightdown}
a660d684 469
803ef874 470\constfunc{bool}{RightDown}{\void}
a660d684 471
cc81d32f 472Returns true if the right mouse button changed to down.
a660d684 473
6f63704f 474
f6bcfd97 475\membersection{wxMouseEvent::RightIsDown}\label{wxmouseeventrightisdown}
a660d684 476
803ef874 477\constfunc{bool}{RightIsDown}{\void}
a660d684 478
cc81d32f 479Returns true if the right mouse button is currently down, independent
a660d684
KB
480of the current event type.
481
6f63704f 482
3e79fa75 483\membersection{wxMouseEvent::RightUp}\label{wxmouseeventrightup}
a660d684 484
803ef874 485\constfunc{bool}{RightUp}{\void}
a660d684 486
cc81d32f 487Returns true if the right mouse button changed to up.
a660d684 488
6f63704f 489
3e79fa75 490\membersection{wxMouseEvent::ShiftDown}\label{wxmouseeventshiftdown}
a660d684 491
803ef874 492\constfunc{bool}{ShiftDown}{\void}
a660d684 493
cc81d32f 494Returns true if the shift key was down at the time of the event.
a660d684 495