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{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.
}
29 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
32 \latexignore{\rtfignore{\wxheading{Members
}}}
34 \membersection{wxMouseEvent::m
\_altDown}
36 \member{bool
}{m
\_altDown}
38 TRUE if the Alt key is pressed down.
40 \membersection{wxMouseEvent::m
\_controlDown}
42 \member{bool
}{m
\_controlDown}
44 TRUE if control key is pressed down.
46 \membersection{wxMouseEvent::m
\_leftDown}
48 \member{bool
}{m
\_leftDown}
50 TRUE if the left mouse button is currently pressed down.
52 \membersection{wxMouseEvent::m
\_middleDown}
54 \member{bool
}{m
\_middleDown}
56 TRUE if the middle mouse button is currently pressed down.
58 \membersection{wxMouseEvent::m
\_rightDown}
60 \member{bool
}{m
\_rightDown}
62 TRUE if the right mouse button is currently pressed down.
64 \membersection{wxMouseEvent::m
\_leftDown}
66 \member{bool
}{m
\_leftDown}
68 TRUE if the left mouse button is currently pressed down.
70 \membersection{wxMouseEvent::m
\_metaDown}
72 \member{bool
}{m
\_metaDown}
74 TRUE if the Meta key is pressed down.
76 \membersection{wxMouseEvent::m
\_shiftDown}
78 \member{bool
}{m
\_shiftDown}
80 TRUE if shift is pressed down.
82 \membersection{wxMouseEvent::m
\_x}
86 X-coordinate of the event.
88 \membersection{wxMouseEvent::m
\_y}
92 Y-coordinate of the event.
94 \membersection{wxMouseEvent::wxMouseEvent
}
96 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0},
\param{int
}{ id =
0}}
98 Constructor. Valid event types are:
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}
116 \membersection{wxMouseEvent::AltDown
}
118 \func{bool
}{AltDown
}{\void}
120 Returns TRUE if the Alt key was down at the time of the event.
122 \membersection{wxMouseEvent::Button
}
124 \func{bool
}{Button
}{\param{int
}{ button
}}
126 Returns TRUE if the identified mouse button is changing state. Valid
127 values of
{\it button
} are
1,
2 or
3 for left, middle and right
128 buttons respectively.
130 Not all mice have middle buttons so a portable application should avoid
133 \membersection{wxMouseEvent::ButtonDClick
}\label{buttondclick
}
135 \func{bool
}{ButtonDClick
}{\param{int
}{ but = -
1}}
137 If the argument is omitted, this returns TRUE if the event was a mouse
138 double click event. Otherwise the argument specifies which double click event
139 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
141 \membersection{wxMouseEvent::ButtonDown
}
143 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
145 If the argument is omitted, this returns TRUE if the event was a mouse
146 button down event. Otherwise the argument specifies which button-down event
147 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
149 \membersection{wxMouseEvent::ButtonUp
}
151 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
153 If the argument is omitted, this returns TRUE if the event was a mouse
154 button up event. Otherwise the argument specifies which button-up event
155 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
157 \membersection{wxMouseEvent::ControlDown
}
159 \func{bool
}{ControlDown
}{\void}
161 Returns TRUE if the control key was down at the time of the event.
163 \membersection{wxMouseEvent::Dragging
}
165 \func{bool
}{Dragging
}{\void}
167 Returns TRUE if this was a dragging event (motion while a button is depressed).
169 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
171 \func{bool
}{Entering
}{\void}
173 Returns TRUE if the mouse was entering the window (MS Windows and Motif).
175 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
177 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
179 \func{float
}{GetX
}{\void}
181 Returns X coordinate of the mouse event position.
183 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
185 \func{float
}{GetY
}{\void}
187 Returns Y coordinate of the mouse event position.
189 \membersection{wxMouseEvent::IsButton
}
191 \func{bool
}{IsButton
}{\void}
193 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
194 that may be tested using
{\it ButtonDown
}).
196 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
198 \func{bool
}{Leaving
}{\void}
200 Returns TRUE if the mouse was leaving the window (MS Windows and Motif).
202 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
204 \membersection{wxMouseEvent::LeftDClick
}
206 \func{bool
}{LeftDClick
}{\void}
208 Returns TRUE if the event was a left double click.
210 \membersection{wxMouseEvent::LeftDown
}
212 \func{bool
}{LeftDown
}{\void}
214 Returns TRUE if the left mouse button changed to down.
216 \membersection{wxMouseEvent::LeftIsDown
}
218 \func{bool
}{LeftIsDown
}{\void}
220 Returns TRUE if the left mouse button is currently down, independent
221 of the current event type.
223 \membersection{wxMouseEvent::LeftUp
}
225 \func{bool
}{LeftUp
}{\void}
227 Returns TRUE if the left mouse button changed to up.
229 \membersection{wxMouseEvent::MetaDown
}
231 \func{bool
}{MetaDown
}{\void}
233 Returns TRUE if the Meta key was down at the time of the event.
235 \membersection{wxMouseEvent::MiddleDClick
}
237 \func{bool
}{MiddleDClick
}{\void}
239 Returns TRUE if the event was a middle double click.
241 \membersection{wxMouseEvent::MiddleDown
}
243 \func{bool
}{MiddleDown
}{\void}
245 Returns TRUE if the middle mouse button changed to down.
247 \membersection{wxMouseEvent::MiddleIsDown
}
249 \func{bool
}{MiddleIsDown
}{\void}
251 Returns TRUE if the middle mouse button is currently down, independent
252 of the current event type.
254 \membersection{wxMouseEvent::MiddleUp
}
256 \func{bool
}{MiddleUp
}{\void}
258 Returns TRUE if the middle mouse button changed to up.
260 \membersection{wxMouseEvent::Moving
}
262 \func{bool
}{Moving
}{\void}
264 Returns TRUE if this was a motion event (no buttons depressed).
266 \membersection{wxMouseEvent::Position
}
268 \func{void
}{Position
}{\param{float *
}{x
},
\param{float *
}{y
}}
270 Sets *x and *y to the position at which the event occurred. If the
271 window is a window, the position is converted to logical units
272 (according to the current mapping mode) with scrolling taken into
273 account. To get back to device units (for example to calculate where on the
274 screen to place a dialog box associated with a window mouse event), use
275 \rtfsp{\bf wxDC::LogicalToDeviceX
} and
{\bf wxDC::LogicalToDeviceY
}.
277 For example, the following code calculates screen pixel coordinates
278 from the frame position, window view start (assuming the window is the only
279 subwindow on the frame and therefore at the top left of it), and the
280 logical event position. A menu is popped up at the position where the
281 mouse click occurred. (Note that the application should also check that
282 the dialog box will be visible on the screen, since the click could have
283 occurred near the screen edge!)
286 float event_x, event_y;
287 event.Position(&event_x, &event_y);
288 frame->GetPosition(&x, &y);
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);
293 char *choice = wxGetSingleChoice("Menu", "Pick a node action",
294 no_choices, choices, frame, mouse_x, mouse_y);
297 \membersection{wxMouseEvent::RightDClick
}
299 \func{bool
}{RightDClick
}{\void}
301 Returns TRUE if the event was a right double click.
303 \membersection{wxMouseEvent::RightDown
}
305 \func{bool
}{RightDown
}{\void}
307 Returns TRUE if the right mouse button changed to down.
309 \membersection{wxMouseEvent::RightIsDown
}
311 \func{bool
}{RightIsDown
}{\void}
313 Returns TRUE if the right mouse button is currently down, independent
314 of the current event type.
316 \membersection{wxMouseEvent::RightUp
}
318 \func{bool
}{RightUp
}{\void}
320 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.