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