1 \section{\class{wxMouseEvent
}}\label{wxmouseevent
}
3 This event class contains information about mouse events.
4 See
\helpref{wxWindow::OnMouseEvent
}{wxwindowonmouseevent
}.
6 {\bf NB:
} Note that under Windows mouse enter and leave events are not natively supported
7 by the system but are generated by wxWindows itself. This has several
8 drawbacks: the LEAVE
\_WINDOW event might be received some time after the mouse
9 left the window and the state variables for it may have changed during this
12 {\bf NB:
} Note the difference between methods like
13 \helpref{LeftDown
}{wxmouseeventleftdown
} and
14 \helpref{LeftIsDown
}{wxmouseeventleftisdown
}: the formet returns
{\tt TRUE
}
15 when the event corresponds to the left mouse button click while the latter
16 returns
{\tt TRUE
} if the left mouse button is currently being pressed. For
17 example, when the user is dragging the mouse you can use
18 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} to test
19 whether the left mouse button is (still) depressed. Also, by convention, if
20 \helpref{LeftDown
}{wxmouseeventleftdown
} returns
{\tt TRUE
},
21 \helpref{LeftIsDown
}{wxmouseeventleftisdown
} will also return
{\tt TRUE
} in
22 wxWindows whatever the underlying GUI behaviour is (which is
23 platform-dependent). The same applies, of course, to other mouse buttons as
26 \wxheading{Derived from
}
28 \helpref{wxEvent
}{wxevent
}
30 \wxheading{Include files
}
34 \wxheading{Event table macros
}
36 To process a mouse event, use these event handler macros to direct input to member
37 functions that take a wxMouseEvent argument.
40 \begin{twocollist
}\itemsep=
0pt
41 \twocolitem{{\bf EVT
\_LEFT\_DOWN(func)
}}{Process a wxEVT
\_LEFT\_DOWN event.
}
42 \twocolitem{{\bf EVT
\_LEFT\_UP(func)
}}{Process a wxEVT
\_LEFT\_UP event.
}
43 \twocolitem{{\bf EVT
\_LEFT\_DCLICK(func)
}}{Process a wxEVT
\_LEFT\_DCLICK event.
}
44 \twocolitem{{\bf EVT
\_MIDDLE\_DOWN(func)
}}{Process a wxEVT
\_MIDDLE\_DOWN event.
}
45 \twocolitem{{\bf EVT
\_MIDDLE\_UP(func)
}}{Process a wxEVT
\_MIDDLE\_UP event.
}
46 \twocolitem{{\bf EVT
\_MIDDLE\_DCLICK(func)
}}{Process a wxEVT
\_MIDDLE\_DCLICK event.
}
47 \twocolitem{{\bf EVT
\_RIGHT\_DOWN(func)
}}{Process a wxEVT
\_RIGHT\_DOWN event.
}
48 \twocolitem{{\bf EVT
\_RIGHT\_UP(func)
}}{Process a wxEVT
\_RIGHT\_UP event.
}
49 \twocolitem{{\bf EVT
\_RIGHT\_DCLICK(func)
}}{Process a wxEVT
\_RIGHT\_DCLICK event.
}
50 \twocolitem{{\bf EVT
\_MOTION(func)
}}{Process a wxEVT
\_MOTION event.
}
51 \twocolitem{{\bf EVT
\_ENTER\_WINDOW(func)
}}{Process a wxEVT
\_ENTER\_WINDOW event.
}
52 \twocolitem{{\bf EVT
\_LEAVE\_WINDOW(func)
}}{Process a wxEVT
\_LEAVE\_WINDOW event.
}
53 \twocolitem{{\bf EVT
\_MOUSEWHEEL(func)
}}{Process a wxEVT
\_MOUSEWHEEL event.
}
54 \twocolitem{{\bf EVT
\_MOUSE\_EVENTS(func)
}}{Process all mouse events.
}
57 \latexignore{\rtfignore{\wxheading{Members
}}}
59 \membersection{wxMouseEvent::m
\_altDown}
61 \member{bool
}{m
\_altDown}
63 TRUE if the Alt key is pressed down.
65 \membersection{wxMouseEvent::m
\_controlDown}
67 \member{bool
}{m
\_controlDown}
69 TRUE if control key is pressed down.
71 \membersection{wxMouseEvent::m
\_leftDown}
73 \member{bool
}{m
\_leftDown}
75 TRUE if the left mouse button is currently pressed down.
77 \membersection{wxMouseEvent::m
\_middleDown}
79 \member{bool
}{m
\_middleDown}
81 TRUE if the middle mouse button is currently pressed down.
83 \membersection{wxMouseEvent::m
\_rightDown}
85 \member{bool
}{m
\_rightDown}
87 TRUE if the right mouse button is currently pressed down.
89 \membersection{wxMouseEvent::m
\_metaDown}
91 \member{bool
}{m
\_metaDown}
93 TRUE if the Meta key is pressed down.
95 \membersection{wxMouseEvent::m
\_shiftDown}
97 \member{bool
}{m
\_shiftDown}
99 TRUE if shift is pressed down.
101 \membersection{wxMouseEvent::m
\_x}
105 X-coordinate of the event.
107 \membersection{wxMouseEvent::m
\_y}
111 Y-coordinate of the event.
113 \membersection{wxMouseEvent::m
\_wheelRotation}
115 \member{int
}{m
\_wheelRotation}
117 The distance the mouse wheel is rotated.
119 \membersection{wxMouseEvent::m
\_wheelDelta}
121 \member{int
}{m
\_wheelDelta}
123 The wheel delta, normally
120.
125 \membersection{wxMouseEvent::m
\_linesPerAction}
127 \member{int
}{m
\_linesPerAction}
129 The configured number of lines (or whatever) to be scrolled per wheel
133 \membersection{wxMouseEvent::wxMouseEvent
}
135 \func{}{wxMouseEvent
}{\param{WXTYPE
}{ mouseEventType =
0},
\param{int
}{ id =
0}}
137 Constructor. Valid event types are:
141 \item {\bf wxEVT
\_ENTER\_WINDOW}
142 \item {\bf wxEVT
\_LEAVE\_WINDOW}
143 \item {\bf wxEVT
\_LEFT\_DOWN}
144 \item {\bf wxEVT
\_LEFT\_UP}
145 \item {\bf wxEVT
\_LEFT\_DCLICK}
146 \item {\bf wxEVT
\_MIDDLE\_DOWN}
147 \item {\bf wxEVT
\_MIDDLE\_UP}
148 \item {\bf wxEVT
\_MIDDLE\_DCLICK}
149 \item {\bf wxEVT
\_RIGHT\_DOWN}
150 \item {\bf wxEVT
\_RIGHT\_UP}
151 \item {\bf wxEVT
\_RIGHT\_DCLICK}
152 \item {\bf wxEVT
\_MOTION}
153 \item {\bf wxEVT
\_MOUSEWHEEL}
156 \membersection{wxMouseEvent::AltDown
}
158 \func{bool
}{AltDown
}{\void}
160 Returns TRUE if the Alt key was down at the time of the event.
162 \membersection{wxMouseEvent::Button
}
164 \func{bool
}{Button
}{\param{int
}{ button
}}
166 Returns TRUE if the identified mouse button is changing state. Valid
167 values of
{\it button
} are
1,
2 or
3 for left, middle and right
168 buttons respectively.
170 Not all mice have middle buttons so a portable application should avoid
173 \membersection{wxMouseEvent::ButtonDClick
}\label{buttondclick
}
175 \func{bool
}{ButtonDClick
}{\param{int
}{ but = -
1}}
177 If the argument is omitted, this returns TRUE if the event was a mouse
178 double click event. Otherwise the argument specifies which double click event
179 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
181 \membersection{wxMouseEvent::ButtonDown
}
183 \func{bool
}{ButtonDown
}{\param{int
}{ but = -
1}}
185 If the argument is omitted, this returns TRUE if the event was a mouse
186 button down event. Otherwise the argument specifies which button-down event
187 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
189 \membersection{wxMouseEvent::ButtonUp
}
191 \func{bool
}{ButtonUp
}{\param{int
}{ but = -
1}}
193 If the argument is omitted, this returns TRUE if the event was a mouse
194 button up event. Otherwise the argument specifies which button-up event
195 was generated (
1,
2 or
3 for left, middle and right buttons respectively).
197 \membersection{wxMouseEvent::ControlDown
}
199 \func{bool
}{ControlDown
}{\void}
201 Returns TRUE if the control key was down at the time of the event.
203 \membersection{wxMouseEvent::Dragging
}
205 \func{bool
}{Dragging
}{\void}
207 Returns TRUE if this was a dragging event (motion while a button is depressed).
209 \membersection{wxMouseEvent::Entering
}\label{wxmouseevententering
}
211 \func{bool
}{Entering
}{\void}
213 Returns TRUE if the mouse was entering the window.
215 See also
\helpref{wxMouseEvent::Leaving
}{wxmouseeventleaving
}.
217 \membersection{wxMouseEvent::GetPosition
}\label{wxmouseeventgetposition
}
219 \constfunc{wxPoint
}{GetPosition
}{\void}
221 \constfunc{void
}{GetPosition
}{\param{wxCoord*
}{ x
},
\param{wxCoord*
}{ y
}}
223 \constfunc{void
}{GetPosition
}{\param{long*
}{ x
},
\param{long*
}{ y
}}
225 Sets *x and *y to the position at which the event occurred.
227 Returns the physical mouse position in pixels.
229 \membersection{wxMouseEvent::GetLogicalPosition
}\label{wxmouseeventgetlogicalposition
}
231 \constfunc{wxPoint
}{GetLogicalPosition
}{\param{const wxDC\&
}{ dc
}}
233 Returns the logical mouse position in pixels (i.e. translated according to the
234 translation set for the DC, which usually indicates that the window has been scrolled).
237 \membersection{wxMouseEvent::GetLinesPerAction
}\label{wxmouseeventgetlinesperaction
}
239 \constfunc{int
}{GetLinesPerAction
}{\void}
241 Returns the configured number of lines (or whatever) to be scrolled per
242 wheel action. Defaults to three.
244 \membersection{wxMouseEvent::GetWheelRotation
}\label{wxmouseeventgetwheelrotation
}
246 \constfunc{int
}{GetWheelRotation
}{\void}
248 Get wheel rotation, positive or negative indicates direction of
249 rotation. Current devices all send an event when rotation is equal to
250 +/-WheelDelta, but this allows for finer resolution devices to be
251 created in the future. Because of this you shouldn't assume that one
252 event is equal to
1 line or whatever, but you should be able to either
253 do partial line scrolling or wait until +/-WheelDelta rotation values
254 have been accumulated before scrolling.
256 \membersection{wxMouseEvent::GetWheelDelta
}\label{wxmouseeventgetwheeldelta
}
258 \constfunc{int
}{GetWheelDelta
}{\void}
260 Get wheel delta, normally
120. This is the threshold for action to be
261 taken, and one such action (for example, scrolling one increment)
262 should occur for each delta.
264 \membersection{wxMouseEvent::GetX
}\label{wxmouseeventgetx
}
266 \constfunc{long
}{GetX
}{\void}
268 Returns X coordinate of the physical mouse event position.
270 \membersection{wxMouseEvent::GetY
}\label{wxmouseeventgety
}
272 \func{long
}{GetY
}{\void}
274 Returns Y coordinate of the physical mouse event position.
276 \membersection{wxMouseEvent::IsButton
}
278 \constfunc{bool
}{IsButton
}{\void}
280 Returns TRUE if the event was a mouse button event (not necessarily a button down event -
281 that may be tested using
{\it ButtonDown
}).
283 \membersection{wxMouseEvent::Leaving
}\label{wxmouseeventleaving
}
285 \constfunc{bool
}{Leaving
}{\void}
287 Returns TRUE if the mouse was leaving the window.
289 See also
\helpref{wxMouseEvent::Entering
}{wxmouseevententering
}.
291 \membersection{wxMouseEvent::LeftDClick
}
293 \constfunc{bool
}{LeftDClick
}{\void}
295 Returns TRUE if the event was a left double click.
297 \membersection{wxMouseEvent::LeftDown
}\label{wxmouseeventleftdown
}
299 \constfunc{bool
}{LeftDown
}{\void}
301 Returns TRUE if the left mouse button changed to down.
303 \membersection{wxMouseEvent::LeftIsDown
}\label{wxmouseeventleftisdown
}
305 \constfunc{bool
}{LeftIsDown
}{\void}
307 Returns TRUE if the left mouse button is currently down, independent
308 of the current event type.
310 Please notice that it is
{\bf not
} the same as
311 \helpref{LeftDown
}{wxmouseeventleftdown
} which returns TRUE if the left mouse
312 button was just pressed. Rather, it describes the state of the mouse button
313 before the event happened.
315 This event is usually used in the mouse event handlers which process "move
316 mouse" messages to determine whether the user is (still) dragging the mouse.
318 \membersection{wxMouseEvent::LeftUp
}
320 \constfunc{bool
}{LeftUp
}{\void}
322 Returns TRUE if the left mouse button changed to up.
324 \membersection{wxMouseEvent::MetaDown
}
326 \constfunc{bool
}{MetaDown
}{\void}
328 Returns TRUE if the Meta key was down at the time of the event.
330 \membersection{wxMouseEvent::MiddleDClick
}
332 \constfunc{bool
}{MiddleDClick
}{\void}
334 Returns TRUE if the event was a middle double click.
336 \membersection{wxMouseEvent::MiddleDown
}
338 \constfunc{bool
}{MiddleDown
}{\void}
340 Returns TRUE if the middle mouse button changed to down.
342 \membersection{wxMouseEvent::MiddleIsDown
}\label{wxmouseeventmiddleisdown
}
344 \constfunc{bool
}{MiddleIsDown
}{\void}
346 Returns TRUE if the middle mouse button is currently down, independent
347 of the current event type.
349 \membersection{wxMouseEvent::MiddleUp
}
351 \constfunc{bool
}{MiddleUp
}{\void}
353 Returns TRUE if the middle mouse button changed to up.
355 \membersection{wxMouseEvent::Moving
}
357 \constfunc{bool
}{Moving
}{\void}
359 Returns TRUE if this was a motion event (no buttons depressed).
361 \membersection{wxMouseEvent::RightDClick
}
363 \constfunc{bool
}{RightDClick
}{\void}
365 Returns TRUE if the event was a right double click.
367 \membersection{wxMouseEvent::RightDown
}
369 \constfunc{bool
}{RightDown
}{\void}
371 Returns TRUE if the right mouse button changed to down.
373 \membersection{wxMouseEvent::RightIsDown
}\label{wxmouseeventrightisdown
}
375 \constfunc{bool
}{RightIsDown
}{\void}
377 Returns TRUE if the right mouse button is currently down, independent
378 of the current event type.
380 \membersection{wxMouseEvent::RightUp
}
382 \constfunc{bool
}{RightUp
}{\void}
384 Returns TRUE if the right mouse button changed to up.
386 \membersection{wxMouseEvent::ShiftDown
}
388 \constfunc{bool
}{ShiftDown
}{\void}
390 Returns TRUE if the shift key was down at the time of the event.