]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mouseevt.tex
added wxCLOSE
[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
6All mouse events involving the buttons use $1$ for the left mouse button, $2$
7for the middle one and $3$ for the right one. Note that not all mice have
8a middle button so a portable application should avoid relying on the events
9from it.
a660d684 10
f4fcc291 11{\bf NB:} Note that under Windows mouse enter and leave events are not natively supported
4aff28fc
VZ
12by the system but are generated by wxWindows itself. This has several
13drawbacks: the LEAVE\_WINDOW event might be received some time after the mouse
14left the window and the state variables for it may have changed during this
15time.
16
9b9337da
RD
17{\bf NB:} Note the difference between methods like
18\helpref{LeftDown}{wxmouseeventleftdown} and
cc81d32f 19\helpref{LeftIsDown}{wxmouseeventleftisdown}: the former returns {\tt true}
f6bcfd97 20when the event corresponds to the left mouse button click while the latter
cc81d32f 21returns {\tt true} if the left mouse button is currently being pressed. For
9b9337da 22example, when the user is dragging the mouse you can use
f6bcfd97
BP
23\helpref{LeftIsDown}{wxmouseeventleftisdown} to test
24whether the left mouse button is (still) depressed. Also, by convention, if
cc81d32f
VS
25\helpref{LeftDown}{wxmouseeventleftdown} returns {\tt true},
26\helpref{LeftIsDown}{wxmouseeventleftisdown} will also return {\tt true} in
f6bcfd97
BP
27wxWindows whatever the underlying GUI behaviour is (which is
28platform-dependent). The same applies, of course, to other mouse buttons as
29well.
30
a660d684
KB
31\wxheading{Derived from}
32
33\helpref{wxEvent}{wxevent}
34
954b8ae6
JS
35\wxheading{Include files}
36
37<wx/event.h>
38
a660d684
KB
39\wxheading{Event table macros}
40
41To process a mouse event, use these event handler macros to direct input to member
42functions that take a wxMouseEvent argument.
43
44\twocolwidtha{7cm}
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.}
d2c52078 58\twocolitem{{\bf EVT\_MOUSEWHEEL(func)}}{Process a wxEVT\_MOUSEWHEEL event.}
5de76427 59\twocolitem{{\bf EVT\_MOUSE\_EVENTS(func)}}{Process all mouse events.}
a660d684
KB
60\end{twocollist}%
61
62\latexignore{\rtfignore{\wxheading{Members}}}
63
64\membersection{wxMouseEvent::m\_altDown}
65
66\member{bool}{m\_altDown}
67
cc81d32f 68true if the Alt key is pressed down.
a660d684
KB
69
70\membersection{wxMouseEvent::m\_controlDown}
71
72\member{bool}{m\_controlDown}
73
cc81d32f 74true if control key is pressed down.
a660d684
KB
75
76\membersection{wxMouseEvent::m\_leftDown}
77
78\member{bool}{m\_leftDown}
79
cc81d32f 80true if the left mouse button is currently pressed down.
a660d684
KB
81
82\membersection{wxMouseEvent::m\_middleDown}
83
84\member{bool}{m\_middleDown}
85
cc81d32f 86true if the middle mouse button is currently pressed down.
a660d684
KB
87
88\membersection{wxMouseEvent::m\_rightDown}
89
90\member{bool}{m\_rightDown}
91
cc81d32f 92true if the right mouse button is currently pressed down.
a660d684 93
a660d684
KB
94\membersection{wxMouseEvent::m\_metaDown}
95
96\member{bool}{m\_metaDown}
97
cc81d32f 98true if the Meta key is pressed down.
a660d684
KB
99
100\membersection{wxMouseEvent::m\_shiftDown}
101
102\member{bool}{m\_shiftDown}
103
cc81d32f 104true if shift is pressed down.
a660d684
KB
105
106\membersection{wxMouseEvent::m\_x}
107
803ef874 108\member{long}{m\_x}
a660d684
KB
109
110X-coordinate of the event.
111
112\membersection{wxMouseEvent::m\_y}
113
803ef874 114\member{long}{m\_y}
a660d684
KB
115
116Y-coordinate of the event.
117
d2c52078
RD
118\membersection{wxMouseEvent::m\_wheelRotation}
119
120\member{int}{m\_wheelRotation}
121
122The distance the mouse wheel is rotated.
123
124\membersection{wxMouseEvent::m\_wheelDelta}
125
126\member{int}{m\_wheelDelta}
127
128The wheel delta, normally 120.
129
130\membersection{wxMouseEvent::m\_linesPerAction}
131
132\member{int}{m\_linesPerAction}
133
134The configured number of lines (or whatever) to be scrolled per wheel
135action.
136
137
a660d684
KB
138\membersection{wxMouseEvent::wxMouseEvent}
139
140\func{}{wxMouseEvent}{\param{WXTYPE}{ mouseEventType = 0}, \param{int}{ id = 0}}
141
142Constructor. Valid event types are:
143
144\begin{itemize}
145\itemsep=0pt
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}
d2c52078 158\item {\bf wxEVT\_MOUSEWHEEL}
a660d684
KB
159\end{itemize}
160
161\membersection{wxMouseEvent::AltDown}
162
163\func{bool}{AltDown}{\void}
164
cc81d32f 165Returns true if the Alt key was down at the time of the event.
a660d684
KB
166
167\membersection{wxMouseEvent::Button}
168
169\func{bool}{Button}{\param{int}{ button}}
170
cc81d32f 171Returns true if the identified mouse button is changing state. Valid
a660d684
KB
172values of {\it button} are 1, 2 or 3 for left, middle and right
173buttons respectively.
174
a660d684
KB
175\membersection{wxMouseEvent::ButtonDClick}\label{buttondclick}
176
177\func{bool}{ButtonDClick}{\param{int}{ but = -1}}
178
cc81d32f 179If the argument is omitted, this returns true if the event was a mouse
a660d684
KB
180double click event. Otherwise the argument specifies which double click event
181was generated (1, 2 or 3 for left, middle and right buttons respectively).
182
183\membersection{wxMouseEvent::ButtonDown}
184
185\func{bool}{ButtonDown}{\param{int}{ but = -1}}
186
cc81d32f 187If the argument is omitted, this returns true if the event was a mouse
a660d684
KB
188button down event. Otherwise the argument specifies which button-down event
189was generated (1, 2 or 3 for left, middle and right buttons respectively).
190
191\membersection{wxMouseEvent::ButtonUp}
192
193\func{bool}{ButtonUp}{\param{int}{ but = -1}}
194
cc81d32f 195If the argument is omitted, this returns true if the event was a mouse
a660d684
KB
196button up event. Otherwise the argument specifies which button-up event
197was generated (1, 2 or 3 for left, middle and right buttons respectively).
198
199\membersection{wxMouseEvent::ControlDown}
200
201\func{bool}{ControlDown}{\void}
202
cc81d32f 203Returns true if the control key was down at the time of the event.
a660d684
KB
204
205\membersection{wxMouseEvent::Dragging}
206
207\func{bool}{Dragging}{\void}
208
cc81d32f 209Returns true if this was a dragging event (motion while a button is depressed).
a660d684
KB
210
211\membersection{wxMouseEvent::Entering}\label{wxmouseevententering}
212
213\func{bool}{Entering}{\void}
214
cc81d32f 215Returns true if the mouse was entering the window.
a660d684
KB
216
217See also \helpref{wxMouseEvent::Leaving}{wxmouseeventleaving}.
218
ec760ec9
VZ
219\membersection{wxMouseEvent::GetButton}\label{wxmouseeventgetbutton}
220
221\constfunc{int}{GetButton}{\void}
222
223Returns the mouse button which generated this event or $-1$ if no button is
224involved (for mouse move, enter or leave event, for example). The value $1$ is
225returned for the left button down, up and double click events, $2$ and $3$ for
226the same events for the middle and the right buttons respectively.
227
803ef874
JS
228\membersection{wxMouseEvent::GetPosition}\label{wxmouseeventgetposition}
229
230\constfunc{wxPoint}{GetPosition}{\void}
231
fa482912
JS
232\constfunc{void}{GetPosition}{\param{wxCoord*}{ x}, \param{wxCoord*}{ y}}
233
234\constfunc{void}{GetPosition}{\param{long*}{ x}, \param{long*}{ y}}
803ef874
JS
235
236Sets *x and *y to the position at which the event occurred.
237
238Returns the physical mouse position in pixels.
239
240\membersection{wxMouseEvent::GetLogicalPosition}\label{wxmouseeventgetlogicalposition}
241
242\constfunc{wxPoint}{GetLogicalPosition}{\param{const wxDC\&}{ dc}}
243
244Returns the logical mouse position in pixels (i.e. translated according to the
245translation set for the DC, which usually indicates that the window has been scrolled).
246
d2c52078
RD
247
248\membersection{wxMouseEvent::GetLinesPerAction}\label{wxmouseeventgetlinesperaction}
249
250\constfunc{int}{GetLinesPerAction}{\void}
251
252Returns the configured number of lines (or whatever) to be scrolled per
d13d99aa 253wheel action. Defaults to three.
d2c52078
RD
254
255\membersection{wxMouseEvent::GetWheelRotation}\label{wxmouseeventgetwheelrotation}
256
257\constfunc{int}{GetWheelRotation}{\void}
258
259Get wheel rotation, positive or negative indicates direction of
260rotation. Current devices all send an event when rotation is equal to
261+/-WheelDelta, but this allows for finer resolution devices to be
262created in the future. Because of this you shouldn't assume that one
263event is equal to 1 line or whatever, but you should be able to either
264do partial line scrolling or wait until +/-WheelDelta rotation values
265have been accumulated before scrolling.
266
267\membersection{wxMouseEvent::GetWheelDelta}\label{wxmouseeventgetwheeldelta}
268
269\constfunc{int}{GetWheelDelta}{\void}
270
271Get wheel delta, normally 120. This is the threshold for action to be
272taken, and one such action (for example, scrolling one increment)
273should occur for each delta.
274
a660d684
KB
275\membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
276
803ef874 277\constfunc{long}{GetX}{\void}
a660d684 278
803ef874 279Returns X coordinate of the physical mouse event position.
a660d684
KB
280
281\membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
282
803ef874 283\func{long}{GetY}{\void}
a660d684 284
803ef874 285Returns Y coordinate of the physical mouse event position.
a660d684
KB
286
287\membersection{wxMouseEvent::IsButton}
288
803ef874 289\constfunc{bool}{IsButton}{\void}
a660d684 290
cc81d32f 291Returns true if the event was a mouse button event (not necessarily a button down event -
a660d684
KB
292that may be tested using {\it ButtonDown}).
293
9b9337da
RD
294\membersection{wxMouseEvent::IsPageScroll}
295
296\constfunc{bool}{IsPageScroll}{\void}
297
cc81d32f 298Returns true if the system has been setup to do page scrolling with
9b9337da
RD
299the mouse wheel instead of line scrolling.
300
a660d684
KB
301\membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
302
803ef874 303\constfunc{bool}{Leaving}{\void}
a660d684 304
cc81d32f 305Returns true if the mouse was leaving the window.
a660d684
KB
306
307See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
308
309\membersection{wxMouseEvent::LeftDClick}
310
803ef874 311\constfunc{bool}{LeftDClick}{\void}
a660d684 312
cc81d32f 313Returns true if the event was a left double click.
a660d684 314
2cdd0d01 315\membersection{wxMouseEvent::LeftDown}\label{wxmouseeventleftdown}
a660d684 316
803ef874 317\constfunc{bool}{LeftDown}{\void}
a660d684 318
cc81d32f 319Returns true if the left mouse button changed to down.
a660d684 320
f6bcfd97 321\membersection{wxMouseEvent::LeftIsDown}\label{wxmouseeventleftisdown}
a660d684 322
803ef874 323\constfunc{bool}{LeftIsDown}{\void}
a660d684 324
cc81d32f 325Returns true if the left mouse button is currently down, independent
a660d684
KB
326of the current event type.
327
d2c52078 328Please notice that it is {\bf not} the same as
cc81d32f 329\helpref{LeftDown}{wxmouseeventleftdown} which returns true if the left mouse
2cdd0d01
VZ
330button was just pressed. Rather, it describes the state of the mouse button
331before the event happened.
332
333This event is usually used in the mouse event handlers which process "move
334mouse" messages to determine whether the user is (still) dragging the mouse.
335
a660d684
KB
336\membersection{wxMouseEvent::LeftUp}
337
803ef874 338\constfunc{bool}{LeftUp}{\void}
a660d684 339
cc81d32f 340Returns true if the left mouse button changed to up.
a660d684
KB
341
342\membersection{wxMouseEvent::MetaDown}
343
803ef874 344\constfunc{bool}{MetaDown}{\void}
a660d684 345
cc81d32f 346Returns true if the Meta key was down at the time of the event.
a660d684
KB
347
348\membersection{wxMouseEvent::MiddleDClick}
349
803ef874 350\constfunc{bool}{MiddleDClick}{\void}
a660d684 351
cc81d32f 352Returns true if the event was a middle double click.
a660d684
KB
353
354\membersection{wxMouseEvent::MiddleDown}
355
803ef874 356\constfunc{bool}{MiddleDown}{\void}
a660d684 357
cc81d32f 358Returns true if the middle mouse button changed to down.
a660d684 359
f6bcfd97 360\membersection{wxMouseEvent::MiddleIsDown}\label{wxmouseeventmiddleisdown}
a660d684 361
803ef874 362\constfunc{bool}{MiddleIsDown}{\void}
a660d684 363
cc81d32f 364Returns true if the middle mouse button is currently down, independent
a660d684
KB
365of the current event type.
366
367\membersection{wxMouseEvent::MiddleUp}
368
803ef874 369\constfunc{bool}{MiddleUp}{\void}
a660d684 370
cc81d32f 371Returns true if the middle mouse button changed to up.
a660d684
KB
372
373\membersection{wxMouseEvent::Moving}
374
803ef874 375\constfunc{bool}{Moving}{\void}
a660d684 376
cc81d32f 377Returns true if this was a motion event (no buttons depressed).
a660d684 378
a660d684
KB
379\membersection{wxMouseEvent::RightDClick}
380
803ef874 381\constfunc{bool}{RightDClick}{\void}
a660d684 382
cc81d32f 383Returns true if the event was a right double click.
a660d684
KB
384
385\membersection{wxMouseEvent::RightDown}
386
803ef874 387\constfunc{bool}{RightDown}{\void}
a660d684 388
cc81d32f 389Returns true if the right mouse button changed to down.
a660d684 390
f6bcfd97 391\membersection{wxMouseEvent::RightIsDown}\label{wxmouseeventrightisdown}
a660d684 392
803ef874 393\constfunc{bool}{RightIsDown}{\void}
a660d684 394
cc81d32f 395Returns true if the right mouse button is currently down, independent
a660d684
KB
396of the current event type.
397
398\membersection{wxMouseEvent::RightUp}
399
803ef874 400\constfunc{bool}{RightUp}{\void}
a660d684 401
cc81d32f 402Returns true if the right mouse button changed to up.
a660d684 403
a660d684
KB
404\membersection{wxMouseEvent::ShiftDown}
405
803ef874 406\constfunc{bool}{ShiftDown}{\void}
a660d684 407
cc81d32f 408Returns true if the shift key was down at the time of the event.
a660d684 409