]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mouseevt.tex
On wxMac don't call Refresh from FullPaint as that is the biggest
[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
322rotation. Current devices all send an event when rotation is equal to
323+/-WheelDelta, but this allows for finer resolution devices to be
324created in the future. Because of this you shouldn't assume that one
325event is equal to 1 line or whatever, but you should be able to either
326do partial line scrolling or wait until +/-WheelDelta rotation values
327have been accumulated before scrolling.
328
6f63704f 329
d2c52078
RD
330\membersection{wxMouseEvent::GetWheelDelta}\label{wxmouseeventgetwheeldelta}
331
332\constfunc{int}{GetWheelDelta}{\void}
333
8e7cd32b 334Get wheel delta, normally $120$. This is the threshold for action to be
d2c52078
RD
335taken, and one such action (for example, scrolling one increment)
336should occur for each delta.
337
6f63704f 338
a660d684
KB
339\membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
340
803ef874 341\constfunc{long}{GetX}{\void}
a660d684 342
803ef874 343Returns X coordinate of the physical mouse event position.
a660d684 344
6f63704f 345
a660d684
KB
346\membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
347
803ef874 348\func{long}{GetY}{\void}
a660d684 349
803ef874 350Returns Y coordinate of the physical mouse event position.
a660d684 351
6f63704f 352
3e79fa75 353\membersection{wxMouseEvent::IsButton}\label{wxmouseeventisbutton}
a660d684 354
803ef874 355\constfunc{bool}{IsButton}{\void}
a660d684 356
cc81d32f 357Returns true if the event was a mouse button event (not necessarily a button down event -
a660d684
KB
358that may be tested using {\it ButtonDown}).
359
6f63704f 360
3e79fa75 361\membersection{wxMouseEvent::IsPageScroll}\label{wxmouseeventispagescroll}
9b9337da
RD
362
363\constfunc{bool}{IsPageScroll}{\void}
364
cc81d32f 365Returns true if the system has been setup to do page scrolling with
9b9337da
RD
366the mouse wheel instead of line scrolling.
367
6f63704f 368
a660d684
KB
369\membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
370
803ef874 371\constfunc{bool}{Leaving}{\void}
a660d684 372
cc81d32f 373Returns true if the mouse was leaving the window.
a660d684
KB
374
375See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
376
6f63704f 377
3e79fa75 378\membersection{wxMouseEvent::LeftDClick}\label{wxmouseeventleftdclick}
a660d684 379
803ef874 380\constfunc{bool}{LeftDClick}{\void}
a660d684 381
cc81d32f 382Returns true if the event was a left double click.
a660d684 383
6f63704f 384
2cdd0d01 385\membersection{wxMouseEvent::LeftDown}\label{wxmouseeventleftdown}
a660d684 386
803ef874 387\constfunc{bool}{LeftDown}{\void}
a660d684 388
cc81d32f 389Returns true if the left mouse button changed to down.
a660d684 390
6f63704f 391
f6bcfd97 392\membersection{wxMouseEvent::LeftIsDown}\label{wxmouseeventleftisdown}
a660d684 393
803ef874 394\constfunc{bool}{LeftIsDown}{\void}
a660d684 395
cc81d32f 396Returns true if the left mouse button is currently down, independent
a660d684
KB
397of the current event type.
398
d2c52078 399Please notice that it is {\bf not} the same as
cc81d32f 400\helpref{LeftDown}{wxmouseeventleftdown} which returns true if the left mouse
2cdd0d01
VZ
401button was just pressed. Rather, it describes the state of the mouse button
402before the event happened.
403
404This event is usually used in the mouse event handlers which process "move
405mouse" messages to determine whether the user is (still) dragging the mouse.
406
6f63704f 407
3e79fa75 408\membersection{wxMouseEvent::LeftUp}\label{wxmouseeventleftup}
a660d684 409
803ef874 410\constfunc{bool}{LeftUp}{\void}
a660d684 411
cc81d32f 412Returns true if the left mouse button changed to up.
a660d684 413
6f63704f 414
a2bd1520 415\membersection{wxMouseEvent::MetaDown}\label{wxmouseeventmetadown}
a660d684 416
803ef874 417\constfunc{bool}{MetaDown}{\void}
a660d684 418
cc81d32f 419Returns true if the Meta key was down at the time of the event.
a660d684 420
6f63704f 421
3e79fa75 422\membersection{wxMouseEvent::MiddleDClick}\label{wxmouseeventmiddledclick}
a660d684 423
803ef874 424\constfunc{bool}{MiddleDClick}{\void}
a660d684 425
cc81d32f 426Returns true if the event was a middle double click.
a660d684 427
6f63704f 428
3e79fa75 429\membersection{wxMouseEvent::MiddleDown}\label{wxmouseeventmiddledown}
a660d684 430
803ef874 431\constfunc{bool}{MiddleDown}{\void}
a660d684 432
cc81d32f 433Returns true if the middle mouse button changed to down.
a660d684 434
6f63704f 435
f6bcfd97 436\membersection{wxMouseEvent::MiddleIsDown}\label{wxmouseeventmiddleisdown}
a660d684 437
803ef874 438\constfunc{bool}{MiddleIsDown}{\void}
a660d684 439
cc81d32f 440Returns true if the middle mouse button is currently down, independent
a660d684
KB
441of the current event type.
442
6f63704f 443
3e79fa75 444\membersection{wxMouseEvent::MiddleUp}\label{wxmouseeventmiddleup}
a660d684 445
803ef874 446\constfunc{bool}{MiddleUp}{\void}
a660d684 447
cc81d32f 448Returns true if the middle mouse button changed to up.
a660d684 449
6f63704f 450
100cf085 451\membersection{wxMouseEvent::Moving}\label{wxmouseeventmoving}
a660d684 452
803ef874 453\constfunc{bool}{Moving}{\void}
a660d684 454
6f63704f
VZ
455Returns true if this was a motion event and no mouse buttons were pressed.
456If any mouse button is held pressed, then this method returns \false and
457\helpref{Dragging}{wxmouseeventdragging} returns \true.
458
a660d684 459
3e79fa75 460\membersection{wxMouseEvent::RightDClick}\label{wxmouseeventrightdclick}
a660d684 461
803ef874 462\constfunc{bool}{RightDClick}{\void}
a660d684 463
cc81d32f 464Returns true if the event was a right double click.
a660d684 465
6f63704f 466
3e79fa75 467\membersection{wxMouseEvent::RightDown}\label{wxmouseeventrightdown}
a660d684 468
803ef874 469\constfunc{bool}{RightDown}{\void}
a660d684 470
cc81d32f 471Returns true if the right mouse button changed to down.
a660d684 472
6f63704f 473
f6bcfd97 474\membersection{wxMouseEvent::RightIsDown}\label{wxmouseeventrightisdown}
a660d684 475
803ef874 476\constfunc{bool}{RightIsDown}{\void}
a660d684 477
cc81d32f 478Returns true if the right mouse button is currently down, independent
a660d684
KB
479of the current event type.
480
6f63704f 481
3e79fa75 482\membersection{wxMouseEvent::RightUp}\label{wxmouseeventrightup}
a660d684 483
803ef874 484\constfunc{bool}{RightUp}{\void}
a660d684 485
cc81d32f 486Returns true if the right mouse button changed to up.
a660d684 487
6f63704f 488
3e79fa75 489\membersection{wxMouseEvent::ShiftDown}\label{wxmouseeventshiftdown}
a660d684 490
803ef874 491\constfunc{bool}{ShiftDown}{\void}
a660d684 492
cc81d32f 493Returns true if the shift key was down at the time of the event.
a660d684 494