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