]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/mouseevt.tex
Added a param to ::Open() to allow the programmer to specify whether opening the...
[wxWidgets.git] / docs / latex / wx / mouseevt.tex
1 \section{\class{wxMouseEvent}}\label{wxmouseevent}
2
3 This event class contains information about mouse events.
4 See \helpref{wxWindow::OnMouseEvent}{wxwindowonmouseevent}.
5
6 {\bf NB: } Note that under Windows mouse enter and leave events are not natively supported
7 by the system but are generated by wxWindows itself. This has several
8 drawbacks: the LEAVE\_WINDOW event might be received some time after the mouse
9 left the window and the state variables for it may have changed during this
10 time.
11
12 {\bf NB: } Note the difference between methods like
13 \helpref{LeftDown}{wxmouseeventleftdown} and
14 \helpref{LeftIsDown}{wxmouseeventleftisdown}: the formet returns {\tt TRUE}
15 when the event corresponds to the left mouse button click while the latter
16 returns {\tt TRUE} if the left mouse button is currently being pressed. For
17 example, when the user is dragging the mouse you can use
18 \helpref{LeftIsDown}{wxmouseeventleftisdown} to test
19 whether the left mouse button is (still) depressed. Also, by convention, if
20 \helpref{LeftDown}{wxmouseeventleftdown} returns {\tt TRUE},
21 \helpref{LeftIsDown}{wxmouseeventleftisdown} will also return {\tt TRUE} in
22 wxWindows whatever the underlying GUI behaviour is (which is
23 platform-dependent). The same applies, of course, to other mouse buttons as
24 well.
25
26 \wxheading{Derived from}
27
28 \helpref{wxEvent}{wxevent}
29
30 \wxheading{Include files}
31
32 <wx/event.h>
33
34 \wxheading{Event table macros}
35
36 To process a mouse event, use these event handler macros to direct input to member
37 functions that take a wxMouseEvent argument.
38
39 \twocolwidtha{7cm}
40 \begin{twocollist}\itemsep=0pt
41 \twocolitem{{\bf EVT\_LEFT\_DOWN(func)}}{Process a wxEVT\_LEFT\_DOWN event.}
42 \twocolitem{{\bf EVT\_LEFT\_UP(func)}}{Process a wxEVT\_LEFT\_UP event.}
43 \twocolitem{{\bf EVT\_LEFT\_DCLICK(func)}}{Process a wxEVT\_LEFT\_DCLICK event.}
44 \twocolitem{{\bf EVT\_MIDDLE\_DOWN(func)}}{Process a wxEVT\_MIDDLE\_DOWN event.}
45 \twocolitem{{\bf EVT\_MIDDLE\_UP(func)}}{Process a wxEVT\_MIDDLE\_UP event.}
46 \twocolitem{{\bf EVT\_MIDDLE\_DCLICK(func)}}{Process a wxEVT\_MIDDLE\_DCLICK event.}
47 \twocolitem{{\bf EVT\_RIGHT\_DOWN(func)}}{Process a wxEVT\_RIGHT\_DOWN event.}
48 \twocolitem{{\bf EVT\_RIGHT\_UP(func)}}{Process a wxEVT\_RIGHT\_UP event.}
49 \twocolitem{{\bf EVT\_RIGHT\_DCLICK(func)}}{Process a wxEVT\_RIGHT\_DCLICK event.}
50 \twocolitem{{\bf EVT\_MOTION(func)}}{Process a wxEVT\_MOTION event.}
51 \twocolitem{{\bf EVT\_ENTER\_WINDOW(func)}}{Process a wxEVT\_ENTER\_WINDOW event.}
52 \twocolitem{{\bf EVT\_LEAVE\_WINDOW(func)}}{Process a wxEVT\_LEAVE\_WINDOW event.}
53 \twocolitem{{\bf EVT\_MOUSE\_EVENTS(func)}}{Process all mouse events.}
54 \end{twocollist}%
55
56 \latexignore{\rtfignore{\wxheading{Members}}}
57
58 \membersection{wxMouseEvent::m\_altDown}
59
60 \member{bool}{m\_altDown}
61
62 TRUE if the Alt key is pressed down.
63
64 \membersection{wxMouseEvent::m\_controlDown}
65
66 \member{bool}{m\_controlDown}
67
68 TRUE if control key is pressed down.
69
70 \membersection{wxMouseEvent::m\_leftDown}
71
72 \member{bool}{m\_leftDown}
73
74 TRUE if the left mouse button is currently pressed down.
75
76 \membersection{wxMouseEvent::m\_middleDown}
77
78 \member{bool}{m\_middleDown}
79
80 TRUE if the middle mouse button is currently pressed down.
81
82 \membersection{wxMouseEvent::m\_rightDown}
83
84 \member{bool}{m\_rightDown}
85
86 TRUE if the right mouse button is currently pressed down.
87
88 \membersection{wxMouseEvent::m\_leftDown}
89
90 \member{bool}{m\_leftDown}
91
92 TRUE if the left mouse button is currently pressed down.
93
94 \membersection{wxMouseEvent::m\_metaDown}
95
96 \member{bool}{m\_metaDown}
97
98 TRUE if the Meta key is pressed down.
99
100 \membersection{wxMouseEvent::m\_shiftDown}
101
102 \member{bool}{m\_shiftDown}
103
104 TRUE if shift is pressed down.
105
106 \membersection{wxMouseEvent::m\_x}
107
108 \member{long}{m\_x}
109
110 X-coordinate of the event.
111
112 \membersection{wxMouseEvent::m\_y}
113
114 \member{long}{m\_y}
115
116 Y-coordinate of the event.
117
118 \membersection{wxMouseEvent::wxMouseEvent}
119
120 \func{}{wxMouseEvent}{\param{WXTYPE}{ mouseEventType = 0}, \param{int}{ id = 0}}
121
122 Constructor. Valid event types are:
123
124 \begin{itemize}
125 \itemsep=0pt
126 \item {\bf wxEVT\_ENTER\_WINDOW}
127 \item {\bf wxEVT\_LEAVE\_WINDOW}
128 \item {\bf wxEVT\_LEFT\_DOWN}
129 \item {\bf wxEVT\_LEFT\_UP}
130 \item {\bf wxEVT\_LEFT\_DCLICK}
131 \item {\bf wxEVT\_MIDDLE\_DOWN}
132 \item {\bf wxEVT\_MIDDLE\_UP}
133 \item {\bf wxEVT\_MIDDLE\_DCLICK}
134 \item {\bf wxEVT\_RIGHT\_DOWN}
135 \item {\bf wxEVT\_RIGHT\_UP}
136 \item {\bf wxEVT\_RIGHT\_DCLICK}
137 \item {\bf wxEVT\_MOTION}
138 \end{itemize}
139
140 \membersection{wxMouseEvent::AltDown}
141
142 \func{bool}{AltDown}{\void}
143
144 Returns TRUE if the Alt key was down at the time of the event.
145
146 \membersection{wxMouseEvent::Button}
147
148 \func{bool}{Button}{\param{int}{ button}}
149
150 Returns TRUE if the identified mouse button is changing state. Valid
151 values of {\it button} are 1, 2 or 3 for left, middle and right
152 buttons respectively.
153
154 Not all mice have middle buttons so a portable application should avoid
155 this one.
156
157 \membersection{wxMouseEvent::ButtonDClick}\label{buttondclick}
158
159 \func{bool}{ButtonDClick}{\param{int}{ but = -1}}
160
161 If the argument is omitted, this returns TRUE if the event was a mouse
162 double click event. Otherwise the argument specifies which double click event
163 was generated (1, 2 or 3 for left, middle and right buttons respectively).
164
165 \membersection{wxMouseEvent::ButtonDown}
166
167 \func{bool}{ButtonDown}{\param{int}{ but = -1}}
168
169 If the argument is omitted, this returns TRUE if the event was a mouse
170 button down event. Otherwise the argument specifies which button-down event
171 was generated (1, 2 or 3 for left, middle and right buttons respectively).
172
173 \membersection{wxMouseEvent::ButtonUp}
174
175 \func{bool}{ButtonUp}{\param{int}{ but = -1}}
176
177 If the argument is omitted, this returns TRUE if the event was a mouse
178 button up event. Otherwise the argument specifies which button-up event
179 was generated (1, 2 or 3 for left, middle and right buttons respectively).
180
181 \membersection{wxMouseEvent::ControlDown}
182
183 \func{bool}{ControlDown}{\void}
184
185 Returns TRUE if the control key was down at the time of the event.
186
187 \membersection{wxMouseEvent::Dragging}
188
189 \func{bool}{Dragging}{\void}
190
191 Returns TRUE if this was a dragging event (motion while a button is depressed).
192
193 \membersection{wxMouseEvent::Entering}\label{wxmouseevententering}
194
195 \func{bool}{Entering}{\void}
196
197 Returns TRUE if the mouse was entering the window.
198
199 See also \helpref{wxMouseEvent::Leaving}{wxmouseeventleaving}.
200
201 \membersection{wxMouseEvent::GetPosition}\label{wxmouseeventgetposition}
202
203 \constfunc{wxPoint}{GetPosition}{\void}
204
205 \constfunc{void}{GetPosition}{\param{wxCoord*}{ x}, \param{wxCoord*}{ y}}
206
207 \constfunc{void}{GetPosition}{\param{long*}{ x}, \param{long*}{ y}}
208
209 Sets *x and *y to the position at which the event occurred.
210
211 Returns the physical mouse position in pixels.
212
213 \membersection{wxMouseEvent::GetLogicalPosition}\label{wxmouseeventgetlogicalposition}
214
215 \constfunc{wxPoint}{GetLogicalPosition}{\param{const wxDC\&}{ dc}}
216
217 Returns the logical mouse position in pixels (i.e. translated according to the
218 translation set for the DC, which usually indicates that the window has been scrolled).
219
220 \membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
221
222 \constfunc{long}{GetX}{\void}
223
224 Returns X coordinate of the physical mouse event position.
225
226 \membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
227
228 \func{long}{GetY}{\void}
229
230 Returns Y coordinate of the physical mouse event position.
231
232 \membersection{wxMouseEvent::IsButton}
233
234 \constfunc{bool}{IsButton}{\void}
235
236 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
237 that may be tested using {\it ButtonDown}).
238
239 \membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
240
241 \constfunc{bool}{Leaving}{\void}
242
243 Returns TRUE if the mouse was leaving the window.
244
245 See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
246
247 \membersection{wxMouseEvent::LeftDClick}
248
249 \constfunc{bool}{LeftDClick}{\void}
250
251 Returns TRUE if the event was a left double click.
252
253 \membersection{wxMouseEvent::LeftDown}\label{wxmouseeventleftdown}
254
255 \constfunc{bool}{LeftDown}{\void}
256
257 Returns TRUE if the left mouse button changed to down.
258
259 \membersection{wxMouseEvent::LeftIsDown}\label{wxmouseeventleftisdown}
260
261 \constfunc{bool}{LeftIsDown}{\void}
262
263 Returns TRUE if the left mouse button is currently down, independent
264 of the current event type.
265
266 Please notice that it is {\bf not} the same as
267 \helpref{LeftDown}{wxmouseeventleftdown} which returns TRUE if the left mouse
268 button was just pressed. Rather, it describes the state of the mouse button
269 before the event happened.
270
271 This event is usually used in the mouse event handlers which process "move
272 mouse" messages to determine whether the user is (still) dragging the mouse.
273
274 \membersection{wxMouseEvent::LeftUp}
275
276 \constfunc{bool}{LeftUp}{\void}
277
278 Returns TRUE if the left mouse button changed to up.
279
280 \membersection{wxMouseEvent::MetaDown}
281
282 \constfunc{bool}{MetaDown}{\void}
283
284 Returns TRUE if the Meta key was down at the time of the event.
285
286 \membersection{wxMouseEvent::MiddleDClick}
287
288 \constfunc{bool}{MiddleDClick}{\void}
289
290 Returns TRUE if the event was a middle double click.
291
292 \membersection{wxMouseEvent::MiddleDown}
293
294 \constfunc{bool}{MiddleDown}{\void}
295
296 Returns TRUE if the middle mouse button changed to down.
297
298 \membersection{wxMouseEvent::MiddleIsDown}\label{wxmouseeventmiddleisdown}
299
300 \constfunc{bool}{MiddleIsDown}{\void}
301
302 Returns TRUE if the middle mouse button is currently down, independent
303 of the current event type.
304
305 \membersection{wxMouseEvent::MiddleUp}
306
307 \constfunc{bool}{MiddleUp}{\void}
308
309 Returns TRUE if the middle mouse button changed to up.
310
311 \membersection{wxMouseEvent::Moving}
312
313 \constfunc{bool}{Moving}{\void}
314
315 Returns TRUE if this was a motion event (no buttons depressed).
316
317 \membersection{wxMouseEvent::RightDClick}
318
319 \constfunc{bool}{RightDClick}{\void}
320
321 Returns TRUE if the event was a right double click.
322
323 \membersection{wxMouseEvent::RightDown}
324
325 \constfunc{bool}{RightDown}{\void}
326
327 Returns TRUE if the right mouse button changed to down.
328
329 \membersection{wxMouseEvent::RightIsDown}\label{wxmouseeventrightisdown}
330
331 \constfunc{bool}{RightIsDown}{\void}
332
333 Returns TRUE if the right mouse button is currently down, independent
334 of the current event type.
335
336 \membersection{wxMouseEvent::RightUp}
337
338 \constfunc{bool}{RightUp}{\void}
339
340 Returns TRUE if the right mouse button changed to up.
341
342 \membersection{wxMouseEvent::ShiftDown}
343
344 \constfunc{bool}{ShiftDown}{\void}
345
346 Returns TRUE if the shift key was down at the time of the event.
347