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