1 \section{\class{wxMouseEvent
}}\label{wxmouseevent
}
3 This event class contains information about mouse events, particularly
4 events received by canvases. See
\helpref{wxWindow::OnMouseEvent
}{wxwindowonmouseevent
}.
6 \wxheading{Derived from
}
8 \helpref{wxEvent
}{wxevent
}
10 \wxheading{Event table macros
}
12 To process a mouse event, use these event handler macros to direct input to member
13 functions that take a wxMouseEvent argument.
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.
}
31 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{wxMouseEvent::m
\_altDown}
35 \member{bool
}{m
\_altDown}
37 TRUE if the Alt key is pressed down.
39 \membersection{wxMouseEvent::m
\_controlDown}
41 \member{bool
}{m
\_controlDown}
43 TRUE if control key is pressed down.
45 \membersection{wxMouseEvent::m
\_leftDown}
47 \member{bool
}{m
\_leftDown}
49 TRUE if the left mouse button is currently pressed down.
51 \membersection{wxMouseEvent::m
\_middleDown}
53 \member{bool
}{m
\_middleDown}
55 TRUE if the middle mouse button is currently pressed down.
57 \membersection{wxMouseEvent::m
\_rightDown}
59 \member{bool
}{m
\_rightDown}
61 TRUE if the right mouse button is currently pressed down.
63 \membersection{wxMouseEvent::m
\_leftDown}
65 \member{bool
}{m
\_leftDown}
67 TRUE if the left mouse button is currently pressed down.
69 \membersection{wxMouseEvent::m
\_metaDown}
71 \member{bool
}{m
\_metaDown}
73 TRUE if the Meta key is pressed down.
75 \membersection{wxMouseEvent::m
\_shiftDown}
77 \member{bool
}{m
\_shiftDown}
79 TRUE if shift is pressed down.
81 \membersection{wxMouseEvent::m
\_x}
85 X-coordinate of the event.
87 \membersection{wxMouseEvent::m
\_y}
91 Y-coordinate of the event.
93 \membersection{wxMouseEvent::wxMouseEvent
}
95 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0},
\param{int
}{ id =
0}}
97 Constructor. Valid event types are:
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}
115 \membersection{wxMouseEvent::AltDown
}
117 \func{bool
}{AltDown
}{\void}
119 Returns TRUE if the Alt key was down at the time of the event.
121 \membersection{wxMouseEvent::Button
}
123 \func{bool
}{Button
}{\param{int
}{ button
}}
125 Returns TRUE if the identified mouse button is changing state. Valid
126 values of
{\it button
} are
1,
2 or
3 for left, middle and right
127 buttons respectively.
129 Not all mice have middle buttons so a portable application should avoid
132 \membersection{wxMouseEvent::ButtonDClick
}\label{buttondclick
}
134 \func{bool
}{ButtonDClick
}{\param{int
}{ but = -
1}}
136 If the argument is omitted, this returns TRUE if the event was a mouse
137 double click event. Otherwise the argument specifies which double click event
138 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
140 \membersection{wxMouseEvent::ButtonDown
}
142 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
144 If the argument is omitted, this returns TRUE if the event was a mouse
145 button down event. Otherwise the argument specifies which button-down event
146 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
148 \membersection{wxMouseEvent::ButtonUp
}
150 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
152 If the argument is omitted, this returns TRUE if the event was a mouse
153 button up event. Otherwise the argument specifies which button-up event
154 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
156 \membersection{wxMouseEvent::ControlDown
}
158 \func{bool
}{ControlDown
}{\void}
160 Returns TRUE if the control key was down at the time of the event.
162 \membersection{wxMouseEvent::Dragging
}
164 \func{bool
}{Dragging
}{\void}
166 Returns TRUE if this was a dragging event (motion while a button is depressed).
168 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
170 \func{bool
}{Entering
}{\void}
172 Returns TRUE if the mouse was entering the canvas (MS Windows and Motif).
174 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
176 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
178 \func{float
}{GetX
}{\void}
180 Returns X coordinate of the mouse event position.
182 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
184 \func{float
}{GetY
}{\void}
186 Returns Y coordinate of the mouse event position.
188 \membersection{wxMouseEvent::IsButton
}
190 \func{bool
}{IsButton
}{\void}
192 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
193 that may be tested using
{\it ButtonDown
}).
195 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
197 \func{bool
}{Leaving
}{\void}
199 Returns TRUE if the mouse was leaving the canvas (MS Windows and Motif).
201 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
203 \membersection{wxMouseEvent::LeftDClick
}
205 \func{bool
}{LeftDClick
}{\void}
207 Returns TRUE if the event was a left double click.
209 \membersection{wxMouseEvent::LeftDown
}
211 \func{bool
}{LeftDown
}{\void}
213 Returns TRUE if the left mouse button changed to down.
215 \membersection{wxMouseEvent::LeftIsDown
}
217 \func{bool
}{LeftIsDown
}{\void}
219 Returns TRUE if the left mouse button is currently down, independent
220 of the current event type.
222 \membersection{wxMouseEvent::LeftUp
}
224 \func{bool
}{LeftUp
}{\void}
226 Returns TRUE if the left mouse button changed to up.
228 \membersection{wxMouseEvent::MetaDown
}
230 \func{bool
}{MetaDown
}{\void}
232 Returns TRUE if the Meta key was down at the time of the event.
234 \membersection{wxMouseEvent::MiddleDClick
}
236 \func{bool
}{MiddleDClick
}{\void}
238 Returns TRUE if the event was a middle double click.
240 \membersection{wxMouseEvent::MiddleDown
}
242 \func{bool
}{MiddleDown
}{\void}
244 Returns TRUE if the middle mouse button changed to down.
246 \membersection{wxMouseEvent::MiddleIsDown
}
248 \func{bool
}{MiddleIsDown
}{\void}
250 Returns TRUE if the middle mouse button is currently down, independent
251 of the current event type.
253 \membersection{wxMouseEvent::MiddleUp
}
255 \func{bool
}{MiddleUp
}{\void}
257 Returns TRUE if the middle mouse button changed to up.
259 \membersection{wxMouseEvent::Moving
}
261 \func{bool
}{Moving
}{\void}
263 Returns TRUE if this was a motion event (no buttons depressed).
265 \membersection{wxMouseEvent::Position
}
267 \func{void
}{Position
}{\param{float *
}{x
},
\param{float *
}{y
}}
269 Sets *x and *y to the position at which the event occurred. If the
270 window is a canvas, the position is converted to logical units
271 (according to the current mapping mode) with scrolling taken into
272 account. To get back to device units (for example to calculate where on the
273 screen to place a dialog box associated with a canvas mouse event), use
274 \rtfsp{\bf wxDC::LogicalToDeviceX
} and
{\bf wxDC::LogicalToDeviceY
}.
276 For example, the following code calculates screen pixel coordinates
277 from the frame position, canvas view start (assuming the canvas is the only
278 subwindow on the frame and therefore at the top left of it), and the
279 logical event position. A menu is popped up at the position where the
280 mouse click occurred. (Note that the application should also check that
281 the dialog box will be visible on the screen, since the click could have
282 occurred near the screen edge!)
285 float event_x, event_y;
286 event.Position(&event_x, &event_y);
287 frame->GetPosition(&x, &y);
288 canvas->ViewStart(&x1, &y1);
289 int mouse_x = (int)(canvas->GetDC()->LogicalToDeviceX(event_x + x - x1);
290 int mouse_y = (int)(canvas->GetDC()->LogicalToDeviceY(event_y + y - y1);
292 char *choice = wxGetSingleChoice("Menu", "Pick a node action",
293 no_choices, choices, frame, mouse_x, mouse_y);
296 \membersection{wxMouseEvent::RightDClick
}
298 \func{bool
}{RightDClick
}{\void}
300 Returns TRUE if the event was a right double click.
302 \membersection{wxMouseEvent::RightDown
}
304 \func{bool
}{RightDown
}{\void}
306 Returns TRUE if the right mouse button changed to down.
308 \membersection{wxMouseEvent::RightIsDown
}
310 \func{bool
}{RightIsDown
}{\void}
312 Returns TRUE if the right mouse button is currently down, independent
313 of the current event type.
315 \membersection{wxMouseEvent::RightUp
}
317 \func{bool
}{RightUp
}{\void}
319 Returns TRUE if the right mouse button changed to up.
322 \membersection{wxMouseEvent::ShiftDown
}
324 \func{bool
}{ShiftDown
}{\void}
326 Returns TRUE if the shift key was down at the time of the event.