File: wx150.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (513 lines) | stat: -rw-r--r-- 13,582 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<HTML>
<head><title>wxMouseEvent</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxmouseevent"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx149.htm#wxmodule"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx151.htm#wxmoveevent"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxMouseEvent</H2>
<P>
This event class contains information about mouse events.
See <A HREF="wx260.htm#wxwindowonmouseevent">wxWindow::OnMouseEvent</A>.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx84.htm#wxevent">wxEvent</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/event.h&gt;<P>
<B><FONT COLOR="#FF0000">Event table macros</FONT></B><P>
To process a mouse event, use these event handler macros to direct input to member
functions that take a wxMouseEvent argument.<P>


<TABLE>


<TR><TD VALIGN=TOP>
<B>EVT_LEFT_DOWN(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_LEFT_DOWN event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_LEFT_UP(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_LEFT_UP event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_LEFT_DCLICK(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_LEFT_DCLICK event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_MIDDLE_DOWN(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_MIDDLE_DOWN event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_MIDDLE_UP(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_MIDDLE_UP event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_MIDDLE_DCLICK(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_MIDDLE_DCLICK event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_RIGHT_DOWN(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_RIGHT_DOWN event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_RIGHT_UP(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_RIGHT_UP event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_RIGHT_DCLICK(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_RIGHT_DCLICK event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_MOTION(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_MOTION event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_ENTER_WINDOW(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_ENTER_WINDOW event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_LEAVE_WINDOW(func)</B>
</TD>

<TD VALIGN=TOP>
Process a wxEVT_LEAVE_WINDOW event.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>EVT_MOUSE_EVENTS(func)</B>
</TD>

<TD VALIGN=TOP>
Process all mouse events.
</TD></TR>


</TABLE>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic575">wxMouseEvent::m_altDown</A><BR>
<A HREF="#topic576">wxMouseEvent::m_controlDown</A><BR>
<A HREF="#topic577">wxMouseEvent::m_leftDown</A><BR>
<A HREF="#topic578">wxMouseEvent::m_middleDown</A><BR>
<A HREF="#topic579">wxMouseEvent::m_rightDown</A><BR>
<A HREF="#topic580">wxMouseEvent::m_leftDown</A><BR>
<A HREF="#topic581">wxMouseEvent::m_metaDown</A><BR>
<A HREF="#topic582">wxMouseEvent::m_shiftDown</A><BR>
<A HREF="#topic583">wxMouseEvent::m_x</A><BR>
<A HREF="#topic584">wxMouseEvent::m_y</A><BR>
<A HREF="#topic585">wxMouseEvent::wxMouseEvent</A><BR>
<A HREF="#topic586">wxMouseEvent::AltDown</A><BR>
<A HREF="#topic587">wxMouseEvent::Button</A><BR>
<A HREF="#buttondclick">wxMouseEvent::ButtonDClick</A><BR>
<A HREF="#topic588">wxMouseEvent::ButtonDown</A><BR>
<A HREF="#topic589">wxMouseEvent::ButtonUp</A><BR>
<A HREF="#topic590">wxMouseEvent::ControlDown</A><BR>
<A HREF="#topic591">wxMouseEvent::Dragging</A><BR>
<A HREF="#wxmouseevententering">wxMouseEvent::Entering</A><BR>
<A HREF="#wxmouseeventgetx">wxMouseEvent::GetX</A><BR>
<A HREF="#wxmouseeventgety">wxMouseEvent::GetY</A><BR>
<A HREF="#topic592">wxMouseEvent::IsButton</A><BR>
<A HREF="#wxmouseeventleaving">wxMouseEvent::Leaving</A><BR>
<A HREF="#topic593">wxMouseEvent::LeftDClick</A><BR>
<A HREF="#topic594">wxMouseEvent::LeftDown</A><BR>
<A HREF="#topic595">wxMouseEvent::LeftIsDown</A><BR>
<A HREF="#topic596">wxMouseEvent::LeftUp</A><BR>
<A HREF="#topic597">wxMouseEvent::MetaDown</A><BR>
<A HREF="#topic598">wxMouseEvent::MiddleDClick</A><BR>
<A HREF="#topic599">wxMouseEvent::MiddleDown</A><BR>
<A HREF="#topic600">wxMouseEvent::MiddleIsDown</A><BR>
<A HREF="#topic601">wxMouseEvent::MiddleUp</A><BR>
<A HREF="#topic602">wxMouseEvent::Moving</A><BR>
<A HREF="#topic603">wxMouseEvent::Position</A><BR>
<A HREF="#topic604">wxMouseEvent::RightDClick</A><BR>
<A HREF="#topic605">wxMouseEvent::RightDown</A><BR>
<A HREF="#topic606">wxMouseEvent::RightIsDown</A><BR>
<A HREF="#topic607">wxMouseEvent::RightUp</A><BR>
<A HREF="#topic608">wxMouseEvent::ShiftDown</A><BR>
<P>

<HR>
<A NAME="topic575"></A>
<H3>wxMouseEvent::m_altDown</H3>
<P>
bool m_altDown<P>
TRUE if the Alt key is pressed down.<P>

<HR>
<A NAME="topic576"></A>
<H3>wxMouseEvent::m_controlDown</H3>
<P>
bool m_controlDown<P>
TRUE if control key is pressed down.<P>

<HR>
<A NAME="topic577"></A>
<H3>wxMouseEvent::m_leftDown</H3>
<P>
bool m_leftDown<P>
TRUE if the left mouse button is currently pressed down.<P>

<HR>
<A NAME="topic578"></A>
<H3>wxMouseEvent::m_middleDown</H3>
<P>
bool m_middleDown<P>
TRUE if the middle mouse button is currently pressed down.<P>

<HR>
<A NAME="topic579"></A>
<H3>wxMouseEvent::m_rightDown</H3>
<P>
bool m_rightDown<P>
TRUE if the right mouse button is currently pressed down.<P>

<HR>
<A NAME="topic580"></A>
<H3>wxMouseEvent::m_leftDown</H3>
<P>
bool m_leftDown<P>
TRUE if the left mouse button is currently pressed down.<P>

<HR>
<A NAME="topic581"></A>
<H3>wxMouseEvent::m_metaDown</H3>
<P>
bool m_metaDown<P>
TRUE if the Meta key is pressed down.<P>

<HR>
<A NAME="topic582"></A>
<H3>wxMouseEvent::m_shiftDown</H3>
<P>
bool m_shiftDown<P>
TRUE if shift is pressed down.<P>

<HR>
<A NAME="topic583"></A>
<H3>wxMouseEvent::m_x</H3>
<P>
float m_x<P>
X-coordinate of the event.<P>

<HR>
<A NAME="topic584"></A>
<H3>wxMouseEvent::m_y</H3>
<P>
float m_y<P>
Y-coordinate of the event.<P>

<HR>
<A NAME="topic585"></A>
<H3>wxMouseEvent::wxMouseEvent</H3>
<P>
<B></B> <B>wxMouseEvent</B>(<B>WXTYPE</B><I> mouseEventType = 0</I>, <B>int</B><I> id = 0</I>)<P>
Constructor. Valid event types are:<P>
<UL>


<LI> <B>wxEVT_ENTER_WINDOW</B>
<LI> <B>wxEVT_LEAVE_WINDOW</B>
<LI> <B>wxEVT_LEFT_DOWN</B>
<LI> <B>wxEVT_LEFT_UP</B>
<LI> <B>wxEVT_LEFT_DCLICK</B>
<LI> <B>wxEVT_MIDDLE_DOWN</B>
<LI> <B>wxEVT_MIDDLE_UP</B>
<LI> <B>wxEVT_MIDDLE_DCLICK</B>
<LI> <B>wxEVT_RIGHT_DOWN</B>
<LI> <B>wxEVT_RIGHT_UP</B>
<LI> <B>wxEVT_RIGHT_DCLICK</B>
<LI> <B>wxEVT_MOTION</B>
</UL>
<P>

<HR>
<A NAME="topic586"></A>
<H3>wxMouseEvent::AltDown</H3>
<P>
<B>bool</B> <B>AltDown</B>()<P>
Returns TRUE if the Alt key was down at the time of the event.<P>

<HR>
<A NAME="topic587"></A>
<H3>wxMouseEvent::Button</H3>
<P>
<B>bool</B> <B>Button</B>(<B>int</B><I> button</I>)<P>
Returns TRUE if the identified mouse button is changing state. Valid
values of <I>button</I> are 1, 2 or 3 for left, middle and right
buttons respectively.<P>
Not all mice have middle buttons so a portable application should avoid
this one.<P>

<HR>
<A NAME="buttondclick"></A>
<H3>wxMouseEvent::ButtonDClick</H3>
<P>
<B>bool</B> <B>ButtonDClick</B>(<B>int</B><I> but = -1</I>)<P>
If the argument is omitted, this returns TRUE if the event was a mouse
double click event. Otherwise the argument specifies which double click event
was generated (1, 2 or 3 for left, middle and right buttons respectively).<P>

<HR>
<A NAME="topic588"></A>
<H3>wxMouseEvent::ButtonDown</H3>
<P>
<B>bool</B> <B>ButtonDown</B>(<B>int</B><I> but = -1</I>)<P>
If the argument is omitted, this returns TRUE if the event was a mouse
button down event. Otherwise the argument specifies which button-down event
was generated (1, 2 or 3 for left, middle and right buttons respectively).<P>

<HR>
<A NAME="topic589"></A>
<H3>wxMouseEvent::ButtonUp</H3>
<P>
<B>bool</B> <B>ButtonUp</B>(<B>int</B><I> but = -1</I>)<P>
If the argument is omitted, this returns TRUE if the event was a mouse
button up event. Otherwise the argument specifies which button-up event
was generated (1, 2 or 3 for left, middle and right buttons respectively).<P>

<HR>
<A NAME="topic590"></A>
<H3>wxMouseEvent::ControlDown</H3>
<P>
<B>bool</B> <B>ControlDown</B>()<P>
Returns TRUE if the control key was down at the time of the event.<P>

<HR>
<A NAME="topic591"></A>
<H3>wxMouseEvent::Dragging</H3>
<P>
<B>bool</B> <B>Dragging</B>()<P>
Returns TRUE if this was a dragging event (motion while a button is depressed).<P>

<HR>
<A NAME="wxmouseevententering"></A>
<H3>wxMouseEvent::Entering</H3>
<P>
<B>bool</B> <B>Entering</B>()<P>
Returns TRUE if the mouse was entering the window (MS Windows and Motif).<P>
See also <A HREF="wx150.htm#wxmouseeventleaving">wxMouseEvent::Leaving</A>.<P>

<HR>
<A NAME="wxmouseeventgetx"></A>
<H3>wxMouseEvent::GetX</H3>
<P>
<B>float</B> <B>GetX</B>()<P>
Returns X coordinate of the mouse event position.<P>

<HR>
<A NAME="wxmouseeventgety"></A>
<H3>wxMouseEvent::GetY</H3>
<P>
<B>float</B> <B>GetY</B>()<P>
Returns Y coordinate of the mouse event position.<P>

<HR>
<A NAME="topic592"></A>
<H3>wxMouseEvent::IsButton</H3>
<P>
<B>bool</B> <B>IsButton</B>()<P>
Returns TRUE if the event was a mouse button event (not necessarily a button down event -
that may be tested using <I>ButtonDown</I>).<P>

<HR>
<A NAME="wxmouseeventleaving"></A>
<H3>wxMouseEvent::Leaving</H3>
<P>
<B>bool</B> <B>Leaving</B>()<P>
Returns TRUE if the mouse was leaving the window (MS Windows and Motif).<P>
See also <A HREF="wx150.htm#wxmouseevententering">wxMouseEvent::Entering</A>.<P>

<HR>
<A NAME="topic593"></A>
<H3>wxMouseEvent::LeftDClick</H3>
<P>
<B>bool</B> <B>LeftDClick</B>()<P>
Returns TRUE if the event was a left double click.<P>

<HR>
<A NAME="topic594"></A>
<H3>wxMouseEvent::LeftDown</H3>
<P>
<B>bool</B> <B>LeftDown</B>()<P>
Returns TRUE if the left mouse button changed to down.<P>

<HR>
<A NAME="topic595"></A>
<H3>wxMouseEvent::LeftIsDown</H3>
<P>
<B>bool</B> <B>LeftIsDown</B>()<P>
Returns TRUE if the left mouse button is currently down, independent
of the current event type.<P>

<HR>
<A NAME="topic596"></A>
<H3>wxMouseEvent::LeftUp</H3>
<P>
<B>bool</B> <B>LeftUp</B>()<P>
Returns TRUE if the left mouse button changed to up.<P>

<HR>
<A NAME="topic597"></A>
<H3>wxMouseEvent::MetaDown</H3>
<P>
<B>bool</B> <B>MetaDown</B>()<P>
Returns TRUE if the Meta key was down at the time of the event.<P>

<HR>
<A NAME="topic598"></A>
<H3>wxMouseEvent::MiddleDClick</H3>
<P>
<B>bool</B> <B>MiddleDClick</B>()<P>
Returns TRUE if the event was a middle double click.<P>

<HR>
<A NAME="topic599"></A>
<H3>wxMouseEvent::MiddleDown</H3>
<P>
<B>bool</B> <B>MiddleDown</B>()<P>
Returns TRUE if the middle mouse button changed to down.<P>

<HR>
<A NAME="topic600"></A>
<H3>wxMouseEvent::MiddleIsDown</H3>
<P>
<B>bool</B> <B>MiddleIsDown</B>()<P>
Returns TRUE if the middle mouse button is currently down, independent
of the current event type.<P>

<HR>
<A NAME="topic601"></A>
<H3>wxMouseEvent::MiddleUp</H3>
<P>
<B>bool</B> <B>MiddleUp</B>()<P>
Returns TRUE if the middle mouse button changed to up.<P>

<HR>
<A NAME="topic602"></A>
<H3>wxMouseEvent::Moving</H3>
<P>
<B>bool</B> <B>Moving</B>()<P>
Returns TRUE if this was a motion event (no buttons depressed).<P>

<HR>
<A NAME="topic603"></A>
<H3>wxMouseEvent::Position</H3>
<P>
<B>void</B> <B>Position</B>(<B>float *</B><I>x</I>, <B>float *</B><I>y</I>)<P>
Sets *x and *y to the position at which the event occurred. If the
window is a window, the position is converted to logical units
(according to the current mapping mode) with scrolling taken into
account. To get back to device units (for example to calculate where on the
screen to place a dialog box associated with a window mouse event), use
<B>wxDC::LogicalToDeviceX</B> and <B>wxDC::LogicalToDeviceY</B>.<P>
For example, the following code calculates screen pixel coordinates
from the frame position, window view start (assuming the window is the only
subwindow on the frame and therefore at the top left of it), and the
logical event position. A menu is popped up at the position where the
mouse click occurred. (Note that the application should also check that
the dialog box will be visible on the screen, since the click could have
occurred near the screen edge!)<P>
<PRE>
  float event_x, event_y;
  event.Position(&event_x, &event_y);
  frame-&gt;GetPosition(&x, &y);
  window-&gt;ViewStart(&x1, &y1);
  int mouse_x = (int)(window-&gt;GetDC()-&gt;LogicalToDeviceX(event_x + x - x1);
  int mouse_y = (int)(window-&gt;GetDC()-&gt;LogicalToDeviceY(event_y + y - y1);

  char *choice = wxGetSingleChoice("Menu", "Pick a node action",
                                 no_choices, choices, frame, mouse_x, mouse_y);
</PRE>

<HR>
<A NAME="topic604"></A>
<H3>wxMouseEvent::RightDClick</H3>
<P>
<B>bool</B> <B>RightDClick</B>()<P>
Returns TRUE if the event was a right double click.<P>

<HR>
<A NAME="topic605"></A>
<H3>wxMouseEvent::RightDown</H3>
<P>
<B>bool</B> <B>RightDown</B>()<P>
Returns TRUE if the right mouse button changed to down.<P>

<HR>
<A NAME="topic606"></A>
<H3>wxMouseEvent::RightIsDown</H3>
<P>
<B>bool</B> <B>RightIsDown</B>()<P>
Returns TRUE if the right mouse button is currently down, independent
of the current event type.<P>

<HR>
<A NAME="topic607"></A>
<H3>wxMouseEvent::RightUp</H3>
<P>
<B>bool</B> <B>RightUp</B>()<P>
Returns TRUE if the right mouse button changed to up.<P>

<HR>
<A NAME="topic608"></A>
<H3>wxMouseEvent::ShiftDown</H3>
<P>
<B>bool</B> <B>ShiftDown</B>()<P>
Returns TRUE if the shift key was down at the time of the event.<P>

</BODY></HTML>