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