]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mouseevt.tex
Changed files to work with wxDataFormat
[wxWidgets.git] / docs / latex / wx / mouseevt.tex
CommitLineData
a660d684
KB
1\section{\class{wxMouseEvent}}\label{wxmouseevent}
2
fe604ccd
JS
3This event class contains information about mouse events.
4See \helpref{wxWindow::OnMouseEvent}{wxwindowonmouseevent}.
a660d684
KB
5
6\wxheading{Derived from}
7
8\helpref{wxEvent}{wxevent}
9
10\wxheading{Event table macros}
11
12To process a mouse event, use these event handler macros to direct input to member
13functions that take a wxMouseEvent argument.
14
15\twocolwidtha{7cm}
16\begin{twocollist}\itemsep=0pt
17\twocolitem{{\bf EVT\_LEFT\_DOWN(func)}}{Process a wxEVT\_LEFT\_DOWN event.}
18\twocolitem{{\bf EVT\_LEFT\_UP(func)}}{Process a wxEVT\_LEFT\_UP event.}
19\twocolitem{{\bf EVT\_LEFT\_DCLICK(func)}}{Process a wxEVT\_LEFT\_DCLICK event.}
20\twocolitem{{\bf EVT\_MIDDLE\_DOWN(func)}}{Process a wxEVT\_MIDDLE\_DOWN event.}
21\twocolitem{{\bf EVT\_MIDDLE\_UP(func)}}{Process a wxEVT\_MIDDLE\_UP event.}
22\twocolitem{{\bf EVT\_MIDDLE\_DCLICK(func)}}{Process a wxEVT\_MIDDLE\_DCLICK event.}
23\twocolitem{{\bf EVT\_RIGHT\_DOWN(func)}}{Process a wxEVT\_RIGHT\_DOWN event.}
24\twocolitem{{\bf EVT\_RIGHT\_UP(func)}}{Process a wxEVT\_RIGHT\_UP event.}
25\twocolitem{{\bf EVT\_RIGHT\_DCLICK(func)}}{Process a wxEVT\_RIGHT\_DCLICK event.}
26\twocolitem{{\bf EVT\_MOTION(func)}}{Process a wxEVT\_MOTION event.}
27\twocolitem{{\bf EVT\_ENTER\_WINDOW(func)}}{Process a wxEVT\_ENTER\_WINDOW event.}
28\twocolitem{{\bf EVT\_LEAVE\_WINDOW(func)}}{Process a wxEVT\_LEAVE\_WINDOW event.}
29\end{twocollist}%
30
31\latexignore{\rtfignore{\wxheading{Members}}}
32
33\membersection{wxMouseEvent::m\_altDown}
34
35\member{bool}{m\_altDown}
36
37TRUE if the Alt key is pressed down.
38
39\membersection{wxMouseEvent::m\_controlDown}
40
41\member{bool}{m\_controlDown}
42
43TRUE if control key is pressed down.
44
45\membersection{wxMouseEvent::m\_leftDown}
46
47\member{bool}{m\_leftDown}
48
49TRUE if the left mouse button is currently pressed down.
50
51\membersection{wxMouseEvent::m\_middleDown}
52
53\member{bool}{m\_middleDown}
54
55TRUE if the middle mouse button is currently pressed down.
56
57\membersection{wxMouseEvent::m\_rightDown}
58
59\member{bool}{m\_rightDown}
60
61TRUE if the right mouse button is currently pressed down.
62
63\membersection{wxMouseEvent::m\_leftDown}
64
65\member{bool}{m\_leftDown}
66
67TRUE if the left mouse button is currently pressed down.
68
69\membersection{wxMouseEvent::m\_metaDown}
70
71\member{bool}{m\_metaDown}
72
73TRUE if the Meta key is pressed down.
74
75\membersection{wxMouseEvent::m\_shiftDown}
76
77\member{bool}{m\_shiftDown}
78
79TRUE if shift is pressed down.
80
81\membersection{wxMouseEvent::m\_x}
82
83\member{float}{m\_x}
84
85X-coordinate of the event.
86
87\membersection{wxMouseEvent::m\_y}
88
89\member{float}{m\_y}
90
91Y-coordinate of the event.
92
93\membersection{wxMouseEvent::wxMouseEvent}
94
95\func{}{wxMouseEvent}{\param{WXTYPE}{ mouseEventType = 0}, \param{int}{ id = 0}}
96
97Constructor. Valid event types are:
98
99\begin{itemize}
100\itemsep=0pt
101\item {\bf wxEVT\_ENTER\_WINDOW}
102\item {\bf wxEVT\_LEAVE\_WINDOW}
103\item {\bf wxEVT\_LEFT\_DOWN}
104\item {\bf wxEVT\_LEFT\_UP}
105\item {\bf wxEVT\_LEFT\_DCLICK}
106\item {\bf wxEVT\_MIDDLE\_DOWN}
107\item {\bf wxEVT\_MIDDLE\_UP}
108\item {\bf wxEVT\_MIDDLE\_DCLICK}
109\item {\bf wxEVT\_RIGHT\_DOWN}
110\item {\bf wxEVT\_RIGHT\_UP}
111\item {\bf wxEVT\_RIGHT\_DCLICK}
112\item {\bf wxEVT\_MOTION}
113\end{itemize}
114
115\membersection{wxMouseEvent::AltDown}
116
117\func{bool}{AltDown}{\void}
118
119Returns TRUE if the Alt key was down at the time of the event.
120
121\membersection{wxMouseEvent::Button}
122
123\func{bool}{Button}{\param{int}{ button}}
124
125Returns TRUE if the identified mouse button is changing state. Valid
126values of {\it button} are 1, 2 or 3 for left, middle and right
127buttons respectively.
128
129Not all mice have middle buttons so a portable application should avoid
130this one.
131
132\membersection{wxMouseEvent::ButtonDClick}\label{buttondclick}
133
134\func{bool}{ButtonDClick}{\param{int}{ but = -1}}
135
136If the argument is omitted, this returns TRUE if the event was a mouse
137double click event. Otherwise the argument specifies which double click event
138was generated (1, 2 or 3 for left, middle and right buttons respectively).
139
140\membersection{wxMouseEvent::ButtonDown}
141
142\func{bool}{ButtonDown}{\param{int}{ but = -1}}
143
144If the argument is omitted, this returns TRUE if the event was a mouse
145button down event. Otherwise the argument specifies which button-down event
146was generated (1, 2 or 3 for left, middle and right buttons respectively).
147
148\membersection{wxMouseEvent::ButtonUp}
149
150\func{bool}{ButtonUp}{\param{int}{ but = -1}}
151
152If the argument is omitted, this returns TRUE if the event was a mouse
153button up event. Otherwise the argument specifies which button-up event
154was generated (1, 2 or 3 for left, middle and right buttons respectively).
155
156\membersection{wxMouseEvent::ControlDown}
157
158\func{bool}{ControlDown}{\void}
159
160Returns TRUE if the control key was down at the time of the event.
161
162\membersection{wxMouseEvent::Dragging}
163
164\func{bool}{Dragging}{\void}
165
166Returns TRUE if this was a dragging event (motion while a button is depressed).
167
168\membersection{wxMouseEvent::Entering}\label{wxmouseevententering}
169
170\func{bool}{Entering}{\void}
171
fe604ccd 172Returns TRUE if the mouse was entering the window (MS Windows and Motif).
a660d684
KB
173
174See also \helpref{wxMouseEvent::Leaving}{wxmouseeventleaving}.
175
176\membersection{wxMouseEvent::GetX}\label{wxmouseeventgetx}
177
178\func{float}{GetX}{\void}
179
180Returns X coordinate of the mouse event position.
181
182\membersection{wxMouseEvent::GetY}\label{wxmouseeventgety}
183
184\func{float}{GetY}{\void}
185
186Returns Y coordinate of the mouse event position.
187
188\membersection{wxMouseEvent::IsButton}
189
190\func{bool}{IsButton}{\void}
191
192Returns TRUE if the event was a mouse button event (not necessarily a button down event -
193that may be tested using {\it ButtonDown}).
194
195\membersection{wxMouseEvent::Leaving}\label{wxmouseeventleaving}
196
197\func{bool}{Leaving}{\void}
198
fe604ccd 199Returns TRUE if the mouse was leaving the window (MS Windows and Motif).
a660d684
KB
200
201See also \helpref{wxMouseEvent::Entering}{wxmouseevententering}.
202
203\membersection{wxMouseEvent::LeftDClick}
204
205\func{bool}{LeftDClick}{\void}
206
207Returns TRUE if the event was a left double click.
208
209\membersection{wxMouseEvent::LeftDown}
210
211\func{bool}{LeftDown}{\void}
212
213Returns TRUE if the left mouse button changed to down.
214
215\membersection{wxMouseEvent::LeftIsDown}
216
217\func{bool}{LeftIsDown}{\void}
218
219Returns TRUE if the left mouse button is currently down, independent
220of the current event type.
221
222\membersection{wxMouseEvent::LeftUp}
223
224\func{bool}{LeftUp}{\void}
225
226Returns TRUE if the left mouse button changed to up.
227
228\membersection{wxMouseEvent::MetaDown}
229
230\func{bool}{MetaDown}{\void}
231
232Returns TRUE if the Meta key was down at the time of the event.
233
234\membersection{wxMouseEvent::MiddleDClick}
235
236\func{bool}{MiddleDClick}{\void}
237
238Returns TRUE if the event was a middle double click.
239
240\membersection{wxMouseEvent::MiddleDown}
241
242\func{bool}{MiddleDown}{\void}
243
244Returns TRUE if the middle mouse button changed to down.
245
246\membersection{wxMouseEvent::MiddleIsDown}
247
248\func{bool}{MiddleIsDown}{\void}
249
250Returns TRUE if the middle mouse button is currently down, independent
251of the current event type.
252
253\membersection{wxMouseEvent::MiddleUp}
254
255\func{bool}{MiddleUp}{\void}
256
257Returns TRUE if the middle mouse button changed to up.
258
259\membersection{wxMouseEvent::Moving}
260
261\func{bool}{Moving}{\void}
262
263Returns TRUE if this was a motion event (no buttons depressed).
264
265\membersection{wxMouseEvent::Position}
266
267\func{void}{Position}{\param{float *}{x}, \param{float *}{y}}
268
269Sets *x and *y to the position at which the event occurred. If the
fe604ccd 270window is a window, the position is converted to logical units
a660d684
KB
271(according to the current mapping mode) with scrolling taken into
272account. To get back to device units (for example to calculate where on the
fe604ccd 273screen to place a dialog box associated with a window mouse event), use
a660d684
KB
274\rtfsp{\bf wxDC::LogicalToDeviceX} and {\bf wxDC::LogicalToDeviceY}.
275
276For example, the following code calculates screen pixel coordinates
fe604ccd 277from the frame position, window view start (assuming the window is the only
a660d684
KB
278subwindow on the frame and therefore at the top left of it), and the
279logical event position. A menu is popped up at the position where the
280mouse click occurred. (Note that the application should also check that
281the dialog box will be visible on the screen, since the click could have
282occurred near the screen edge!)
283
284\begin{verbatim}
285 float event_x, event_y;
286 event.Position(&event_x, &event_y);
287 frame->GetPosition(&x, &y);
fe604ccd
JS
288 window->ViewStart(&x1, &y1);
289 int mouse_x = (int)(window->GetDC()->LogicalToDeviceX(event_x + x - x1);
290 int mouse_y = (int)(window->GetDC()->LogicalToDeviceY(event_y + y - y1);
a660d684
KB
291
292 char *choice = wxGetSingleChoice("Menu", "Pick a node action",
293 no_choices, choices, frame, mouse_x, mouse_y);
294\end{verbatim}
295
296\membersection{wxMouseEvent::RightDClick}
297
298\func{bool}{RightDClick}{\void}
299
300Returns TRUE if the event was a right double click.
301
302\membersection{wxMouseEvent::RightDown}
303
304\func{bool}{RightDown}{\void}
305
306Returns TRUE if the right mouse button changed to down.
307
308\membersection{wxMouseEvent::RightIsDown}
309
310\func{bool}{RightIsDown}{\void}
311
312Returns TRUE if the right mouse button is currently down, independent
313of the current event type.
314
315\membersection{wxMouseEvent::RightUp}
316
317\func{bool}{RightUp}{\void}
318
319Returns TRUE if the right mouse button changed to up.
320
a660d684
KB
321\membersection{wxMouseEvent::ShiftDown}
322
323\func{bool}{ShiftDown}{\void}
324
325Returns TRUE if the shift key was down at the time of the event.
326