1 \section{\class{wxMouseEvent
}}\label{wxmouseevent
}
3 This event class contains information about mouse events.
4 See
\helpref{wxWindow::OnMouseEvent
}{wxwindowonmouseevent
}.
6 \wxheading{Derived from
}
8 \helpref{wxEvent
}{wxevent
}
10 \wxheading{Include files
}
14 \wxheading{Event table macros
}
16 To process a mouse event, use these event handler macros to direct input to member
17 functions that take a wxMouseEvent argument.
20 \begin{twocollist
}\itemsep=
0pt
21 \twocolitem{{\bf EVT
\_LEFT\_DOWN(func)
}}{Process a wxEVT
\_LEFT\_DOWN event.
}
22 \twocolitem{{\bf EVT
\_LEFT\_UP(func)
}}{Process a wxEVT
\_LEFT\_UP event.
}
23 \twocolitem{{\bf EVT
\_LEFT\_DCLICK(func)
}}{Process a wxEVT
\_LEFT\_DCLICK event.
}
24 \twocolitem{{\bf EVT
\_MIDDLE\_DOWN(func)
}}{Process a wxEVT
\_MIDDLE\_DOWN event.
}
25 \twocolitem{{\bf EVT
\_MIDDLE\_UP(func)
}}{Process a wxEVT
\_MIDDLE\_UP event.
}
26 \twocolitem{{\bf EVT
\_MIDDLE\_DCLICK(func)
}}{Process a wxEVT
\_MIDDLE\_DCLICK event.
}
27 \twocolitem{{\bf EVT
\_RIGHT\_DOWN(func)
}}{Process a wxEVT
\_RIGHT\_DOWN event.
}
28 \twocolitem{{\bf EVT
\_RIGHT\_UP(func)
}}{Process a wxEVT
\_RIGHT\_UP event.
}
29 \twocolitem{{\bf EVT
\_RIGHT\_DCLICK(func)
}}{Process a wxEVT
\_RIGHT\_DCLICK event.
}
30 \twocolitem{{\bf EVT
\_MOTION(func)
}}{Process a wxEVT
\_MOTION event.
}
31 \twocolitem{{\bf EVT
\_ENTER\_WINDOW(func)
}}{Process a wxEVT
\_ENTER\_WINDOW event.
}
32 \twocolitem{{\bf EVT
\_LEAVE\_WINDOW(func)
}}{Process a wxEVT
\_LEAVE\_WINDOW event.
}
33 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
36 \latexignore{\rtfignore{\wxheading{Members
}}}
38 \membersection{wxMouseEvent::m
\_altDown}
40 \member{bool
}{m
\_altDown}
42 TRUE if the Alt key is pressed down.
44 \membersection{wxMouseEvent::m
\_controlDown}
46 \member{bool
}{m
\_controlDown}
48 TRUE if control key is pressed down.
50 \membersection{wxMouseEvent::m
\_leftDown}
52 \member{bool
}{m
\_leftDown}
54 TRUE if the left mouse button is currently pressed down.
56 \membersection{wxMouseEvent::m
\_middleDown}
58 \member{bool
}{m
\_middleDown}
60 TRUE if the middle mouse button is currently pressed down.
62 \membersection{wxMouseEvent::m
\_rightDown}
64 \member{bool
}{m
\_rightDown}
66 TRUE if the right mouse button is currently pressed down.
68 \membersection{wxMouseEvent::m
\_leftDown}
70 \member{bool
}{m
\_leftDown}
72 TRUE if the left mouse button is currently pressed down.
74 \membersection{wxMouseEvent::m
\_metaDown}
76 \member{bool
}{m
\_metaDown}
78 TRUE if the Meta key is pressed down.
80 \membersection{wxMouseEvent::m
\_shiftDown}
82 \member{bool
}{m
\_shiftDown}
84 TRUE if shift is pressed down.
86 \membersection{wxMouseEvent::m
\_x}
90 X-coordinate of the event.
92 \membersection{wxMouseEvent::m
\_y}
96 Y-coordinate of the event.
98 \membersection{wxMouseEvent::wxMouseEvent
}
100 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0},
\param{int
}{ id =
0}}
102 Constructor. Valid event types are:
106 \item {\bf wxEVT
\_ENTER\_WINDOW}
107 \item {\bf wxEVT
\_LEAVE\_WINDOW}
108 \item {\bf wxEVT
\_LEFT\_DOWN}
109 \item {\bf wxEVT
\_LEFT\_UP}
110 \item {\bf wxEVT
\_LEFT\_DCLICK}
111 \item {\bf wxEVT
\_MIDDLE\_DOWN}
112 \item {\bf wxEVT
\_MIDDLE\_UP}
113 \item {\bf wxEVT
\_MIDDLE\_DCLICK}
114 \item {\bf wxEVT
\_RIGHT\_DOWN}
115 \item {\bf wxEVT
\_RIGHT\_UP}
116 \item {\bf wxEVT
\_RIGHT\_DCLICK}
117 \item {\bf wxEVT
\_MOTION}
120 \membersection{wxMouseEvent::AltDown
}
122 \func{bool
}{AltDown
}{\void}
124 Returns TRUE if the Alt key was down at the time of the event.
126 \membersection{wxMouseEvent::Button
}
128 \func{bool
}{Button
}{\param{int
}{ button
}}
130 Returns TRUE if the identified mouse button is changing state. Valid
131 values of
{\it button
} are
1,
2 or
3 for left, middle and right
132 buttons respectively.
134 Not all mice have middle buttons so a portable application should avoid
137 \membersection{wxMouseEvent::ButtonDClick
}\label{buttondclick
}
139 \func{bool
}{ButtonDClick
}{\param{int
}{ but = -
1}}
141 If the argument is omitted, this returns TRUE if the event was a mouse
142 double click event. Otherwise the argument specifies which double click event
143 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
145 \membersection{wxMouseEvent::ButtonDown
}
147 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
149 If the argument is omitted, this returns TRUE if the event was a mouse
150 button down event. Otherwise the argument specifies which button-down event
151 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
153 \membersection{wxMouseEvent::ButtonUp
}
155 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
157 If the argument is omitted, this returns TRUE if the event was a mouse
158 button up event. Otherwise the argument specifies which button-up event
159 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
161 \membersection{wxMouseEvent::ControlDown
}
163 \func{bool
}{ControlDown
}{\void}
165 Returns TRUE if the control key was down at the time of the event.
167 \membersection{wxMouseEvent::Dragging
}
169 \func{bool
}{Dragging
}{\void}
171 Returns TRUE if this was a dragging event (motion while a button is depressed).
173 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
175 \func{bool
}{Entering
}{\void}
177 Returns TRUE if the mouse was entering the window (MS Windows and Motif).
179 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
181 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
183 \func{float
}{GetX
}{\void}
185 Returns X coordinate of the mouse event position.
187 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
189 \func{float
}{GetY
}{\void}
191 Returns Y coordinate of the mouse event position.
193 \membersection{wxMouseEvent::IsButton
}
195 \func{bool
}{IsButton
}{\void}
197 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
198 that may be tested using
{\it ButtonDown
}).
200 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
202 \func{bool
}{Leaving
}{\void}
204 Returns TRUE if the mouse was leaving the window (MS Windows and Motif).
206 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
208 \membersection{wxMouseEvent::LeftDClick
}
210 \func{bool
}{LeftDClick
}{\void}
212 Returns TRUE if the event was a left double click.
214 \membersection{wxMouseEvent::LeftDown
}
216 \func{bool
}{LeftDown
}{\void}
218 Returns TRUE if the left mouse button changed to down.
220 \membersection{wxMouseEvent::LeftIsDown
}
222 \func{bool
}{LeftIsDown
}{\void}
224 Returns TRUE if the left mouse button is currently down, independent
225 of the current event type.
227 \membersection{wxMouseEvent::LeftUp
}
229 \func{bool
}{LeftUp
}{\void}
231 Returns TRUE if the left mouse button changed to up.
233 \membersection{wxMouseEvent::MetaDown
}
235 \func{bool
}{MetaDown
}{\void}
237 Returns TRUE if the Meta key was down at the time of the event.
239 \membersection{wxMouseEvent::MiddleDClick
}
241 \func{bool
}{MiddleDClick
}{\void}
243 Returns TRUE if the event was a middle double click.
245 \membersection{wxMouseEvent::MiddleDown
}
247 \func{bool
}{MiddleDown
}{\void}
249 Returns TRUE if the middle mouse button changed to down.
251 \membersection{wxMouseEvent::MiddleIsDown
}
253 \func{bool
}{MiddleIsDown
}{\void}
255 Returns TRUE if the middle mouse button is currently down, independent
256 of the current event type.
258 \membersection{wxMouseEvent::MiddleUp
}
260 \func{bool
}{MiddleUp
}{\void}
262 Returns TRUE if the middle mouse button changed to up.
264 \membersection{wxMouseEvent::Moving
}
266 \func{bool
}{Moving
}{\void}
268 Returns TRUE if this was a motion event (no buttons depressed).
270 \membersection{wxMouseEvent::Position
}
272 \func{void
}{Position
}{\param{float *
}{x
},
\param{float *
}{y
}}
274 Sets *x and *y to the position at which the event occurred. If the
275 window is a window, the position is converted to logical units
276 (according to the current mapping mode) with scrolling taken into
277 account. To get back to device units (for example to calculate where on the
278 screen to place a dialog box associated with a window mouse event), use
279 \rtfsp{\bf wxDC::LogicalToDeviceX
} and
{\bf wxDC::LogicalToDeviceY
}.
281 For example, the following code calculates screen pixel coordinates
282 from the frame position, window view start (assuming the window is the only
283 subwindow on the frame and therefore at the top left of it), and the
284 logical event position. A menu is popped up at the position where the
285 mouse click occurred. (Note that the application should also check that
286 the dialog box will be visible on the screen, since the click could have
287 occurred near the screen edge!)
290 float event_x, event_y;
291 event.Position(&event_x, &event_y);
292 frame->GetPosition(&x, &y);
293 window->ViewStart(&x1, &y1);
294 int mouse_x = (int)(window->GetDC()->LogicalToDeviceX(event_x + x - x1);
295 int mouse_y = (int)(window->GetDC()->LogicalToDeviceY(event_y + y - y1);
297 char *choice = wxGetSingleChoice("Menu", "Pick a node action",
298 no_choices, choices, frame, mouse_x, mouse_y);
301 \membersection{wxMouseEvent::RightDClick
}
303 \func{bool
}{RightDClick
}{\void}
305 Returns TRUE if the event was a right double click.
307 \membersection{wxMouseEvent::RightDown
}
309 \func{bool
}{RightDown
}{\void}
311 Returns TRUE if the right mouse button changed to down.
313 \membersection{wxMouseEvent::RightIsDown
}
315 \func{bool
}{RightIsDown
}{\void}
317 Returns TRUE if the right mouse button is currently down, independent
318 of the current event type.
320 \membersection{wxMouseEvent::RightUp
}
322 \func{bool
}{RightUp
}{\void}
324 Returns TRUE if the right mouse button changed to up.
326 \membersection{wxMouseEvent::ShiftDown
}
328 \func{bool
}{ShiftDown
}{\void}
330 Returns TRUE if the shift key was down at the time of the event.