1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wx*Event classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This event class contains information about keypress (character) events.
15 Notice that there are three different kinds of keyboard events in wxWidgets:
16 key down and up events and char events. The difference between the first two
17 is clear - the first corresponds to a key press and the second to a key
18 release - otherwise they are identical. Just note that if the key is
19 maintained in a pressed state you will typically get a lot of (automatically
20 generated) down events but only one up so it is wrong to assume that there is
21 one up event corresponding to each down one.
23 Both key events provide untranslated key codes while the char event carries
24 the translated one. The untranslated code for alphanumeric keys is always
25 an upper case value. For the other keys it is one of @c WXK_XXX values
26 from the @ref page_keycodes.
27 The translated key is, in general, the character the user expects to appear
28 as the result of the key combination when typing the text into a text entry
31 A few examples to clarify this (all assume that CAPS LOCK is unpressed
32 and the standard US keyboard): when the @c 'A' key is pressed, the key down
33 event key code is equal to @c ASCII A == 65. But the char event key code
34 is @c ASCII a == 97. On the other hand, if you press both SHIFT and
35 @c 'A' keys simultaneously , the key code in key down event will still be
36 just @c 'A' while the char event key code parameter will now be @c 'A'
39 Although in this simple case it is clear that the correct key code could be
40 found in the key down event handler by checking the value returned by
41 wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as
42 for non-alphanumeric keys the translation is keyboard-layout dependent and
43 can only be done properly by the system itself.
45 Another kind of translation is done when the control key is pressed: for
46 example, for CTRL-A key press the key down event still carries the
47 same key code @c 'a' as usual but the char event will have key code of 1,
48 the ASCII value of this key combination.
50 You may discover how the other keys on your system behave interactively by
51 running the @ref page_samples_text wxWidgets sample and pressing some keys
52 in any of the text controls shown in it.
54 @b Tip: be sure to call @c event.Skip() for events that you don't process in
55 key event function, otherwise menu shortcuts may cease to work under Windows.
57 @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler
58 does not call @c event.Skip() then the corresponding char event
59 (@c EVT_CHAR) will not happen.
60 This is by design and enables the programs that handle both types of
61 events to be a bit simpler.
63 @note For Windows programmers: The key and char events in wxWidgets are
64 similar to but slightly different from Windows @c WM_KEYDOWN and
65 @c WM_CHAR events. In particular, Alt-x combination will generate a
66 char event in wxWidgets (unless it is used as an accelerator).
69 @beginEventTable{wxKeyEvent}
70 @event{EVT_KEY_DOWN(func)}:
71 Process a wxEVT_KEY_DOWN event (any key has been pressed).
72 @event{EVT_KEY_UP(func)}:
73 Process a wxEVT_KEY_UP event (any key has been released).
74 @event{EVT_CHAR(func)}:
75 Process a wxEVT_CHAR event.
81 class wxKeyEvent
: public wxEvent
86 Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK.
88 wxKeyEvent(wxEventType keyEventType
= wxEVT_NULL
);
91 Returns @true if the Alt key was down at the time of the key event.
93 Notice that GetModifiers() is easier to use correctly than this function
94 so you should consider using it in new code.
99 CMD is a pseudo key which is the same as Control for PC and Unix
100 platforms but the special APPLE (a.k.a as COMMAND) key under Macs:
101 it makes often sense to use it instead of, say, ControlDown() because Cmd
102 key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still
103 exists, just not used for this purpose under Mac). So for non-Mac platforms
104 this is the same as ControlDown() and under Mac this is the same as MetaDown().
106 bool CmdDown() const;
109 Returns @true if the control key was down at the time of the key event.
111 Notice that GetModifiers() is easier to use correctly than this function
112 so you should consider using it in new code.
114 bool ControlDown() const;
117 Returns the virtual key code. ASCII events return normal ASCII values,
118 while non-ASCII events return values such as @b WXK_LEFT for the left cursor
119 key. See @ref page_keycodes for a full list of the virtual key codes.
121 Note that in Unicode build, the returned value is meaningful only if the
122 user entered a character that can be represented in current locale's default
123 charset. You can obtain the corresponding Unicode character using GetUnicodeKey().
125 int GetKeyCode() const;
128 Return the bitmask of modifier keys which were pressed when this event
129 happened. See @ref page_keymodifiers for the full list of modifiers.
131 Notice that this function is easier to use correctly than, for example,
132 ControlDown() because when using the latter you also have to remember to
133 test that none of the other modifiers is pressed:
136 if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() )
137 ... handle Ctrl-XXX ...
140 and forgetting to do it can result in serious program bugs (e.g. program
141 not working with European keyboard layout where ALTGR key which is seen by
142 the program as combination of CTRL and ALT is used). On the other hand,
143 you can simply write:
146 if ( GetModifiers() == wxMOD_CONTROL )
147 ... handle Ctrl-XXX ...
152 int GetModifiers() const;
156 Obtains the position (in client coordinates) at which the key was pressed.
158 wxPoint
GetPosition() const;
159 void GetPosition(long* x
, long* y
) const;
163 Returns the raw key code for this event. This is a platform-dependent scan code
164 which should only be used in advanced applications.
166 @note Currently the raw key codes are not supported by all ports, use
167 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
169 wxUint32
GetRawKeyCode() const;
172 Returns the low level key flags for this event. The flags are
173 platform-dependent and should only be used in advanced applications.
175 @note Currently the raw key flags are not supported by all ports, use
176 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
178 wxUint32
GetRawKeyFlags() const;
181 Returns the Unicode character corresponding to this key event.
183 This function is only available in Unicode build, i.e. when
184 @c wxUSE_UNICODE is 1.
186 wxChar
GetUnicodeKey() const;
189 Returns the X position (in client coordinates) of the event.
191 wxCoord
GetX() const;
194 Returns the Y position (in client coordinates) of the event.
196 wxCoord
GetY() const;
199 Returns @true if either CTRL or ALT keys was down at the time of the
202 Note that this function does not take into account neither SHIFT nor
203 META key states (the reason for ignoring the latter is that it is
204 common for NUMLOCK key to be configured as META under X but the key
205 presses even while NUMLOCK is on should be still processed normally).
207 bool HasModifiers() const;
210 Returns @true if the Meta key was down at the time of the key event.
212 Notice that GetModifiers() is easier to use correctly than this function
213 so you should consider using it in new code.
215 bool MetaDown() const;
218 Returns @true if the shift key was down at the time of the key event.
220 Notice that GetModifiers() is easier to use correctly than this function
221 so you should consider using it in new code.
223 bool ShiftDown() const;
229 @class wxJoystickEvent
232 This event class contains information about joystick events, particularly
233 events received by windows.
235 @beginEventTable{wxJoystickEvent}
236 @style{EVT_JOY_BUTTON_DOWN(func)}:
237 Process a wxEVT_JOY_BUTTON_DOWN event.
238 @style{EVT_JOY_BUTTON_UP(func)}:
239 Process a wxEVT_JOY_BUTTON_UP event.
240 @style{EVT_JOY_MOVE(func)}:
241 Process a wxEVT_JOY_MOVE event.
242 @style{EVT_JOY_ZMOVE(func)}:
243 Process a wxEVT_JOY_ZMOVE event.
244 @style{EVT_JOYSTICK_EVENTS(func)}:
245 Processes all joystick events.
253 class wxJoystickEvent
: public wxEvent
259 wxJoystickEvent(wxEventType eventType
= wxEVT_NULL
, int state
= 0,
260 int joystick
= wxJOYSTICK1
,
264 Returns @true if the event was a down event from the specified button
268 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
269 indicate any button down event.
271 bool ButtonDown(int button
= wxJOY_BUTTON_ANY
) const;
274 Returns @true if the specified button (or any button) was in a down state.
277 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
278 indicate any button down event.
280 bool ButtonIsDown(int button
= wxJOY_BUTTON_ANY
) const;
283 Returns @true if the event was an up event from the specified button
287 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
288 indicate any button down event.
290 bool ButtonUp(int button
= wxJOY_BUTTON_ANY
) const;
293 Returns the identifier of the button changing state.
295 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
297 int GetButtonChange() const;
300 Returns the down state of the buttons.
302 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
304 int GetButtonState() const;
307 Returns the identifier of the joystick generating the event - one of
308 wxJOYSTICK1 and wxJOYSTICK2.
310 int GetJoystick() const;
313 Returns the x, y position of the joystick event.
315 wxPoint
GetPosition() const;
318 Returns the z position of the joystick event.
320 int GetZPosition() const;
323 Returns @true if this was a button up or down event
324 (@e not 'is any button down?').
326 bool IsButton() const;
329 Returns @true if this was an x, y move event.
334 Returns @true if this was a z move event.
336 bool IsZMove() const;
342 @class wxScrollWinEvent
345 A scroll event holds information about events sent from scrolling windows.
348 @beginEventTable{wxScrollWinEvent}
349 You can use the EVT_SCROLLWIN* macros for intercepting scroll window events
350 from the receiving window.
351 @event{EVT_SCROLLWIN(func)}:
352 Process all scroll events.
353 @event{EVT_SCROLLWIN_TOP(func)}:
354 Process wxEVT_SCROLLWIN_TOP scroll-to-top events.
355 @event{EVT_SCROLLWIN_BOTTOM(func)}:
356 Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events.
357 @event{EVT_SCROLLWIN_LINEUP(func)}:
358 Process wxEVT_SCROLLWIN_LINEUP line up events.
359 @event{EVT_SCROLLWIN_LINEDOWN(func)}:
360 Process wxEVT_SCROLLWIN_LINEDOWN line down events.
361 @event{EVT_SCROLLWIN_PAGEUP(func)}:
362 Process wxEVT_SCROLLWIN_PAGEUP page up events.
363 @event{EVT_SCROLLWIN_PAGEDOWN(func)}:
364 Process wxEVT_SCROLLWIN_PAGEDOWN page down events.
365 @event{EVT_SCROLLWIN_THUMBTRACK(func)}:
366 Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events
367 (frequent events sent as the user drags the thumbtrack).
368 @event{EVT_SCROLLWIN_THUMBRELEASE(func)}:
369 Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events.
376 @see wxScrollEvent, @ref overview_eventhandling
378 class wxScrollWinEvent
: public wxEvent
384 wxScrollWinEvent(wxEventType commandType
= wxEVT_NULL
, int pos
= 0,
385 int orientation
= 0);
388 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
391 @todo wxHORIZONTAL and wxVERTICAL should go in their own enum
393 int GetOrientation() const;
396 Returns the position of the scrollbar for the thumb track and release events.
398 Note that this field can't be used for the other events, you need to query
399 the window itself for the current position in that case.
401 int GetPosition() const;
407 @class wxSysColourChangedEvent
410 This class is used for system colour change events, which are generated
411 when the user changes the colour settings using the control panel.
412 This is only appropriate under Windows.
415 The default event handler for this event propagates the event to child windows,
416 since Windows only sends the events to top-level windows.
417 If intercepting this event for a top-level window, remember to call the base
418 class handler, or to pass the event on to the window's children explicitly.
420 @beginEventTable{wxSysColourChangedEvent}
421 @event{EVT_SYS_COLOUR_CHANGED(func)}:
422 Process a wxEVT_SYS_COLOUR_CHANGED event.
428 @see @ref overview_eventhandling
430 class wxSysColourChangedEvent
: public wxEvent
436 wxSysColourChangedEvent();
442 @class wxWindowCreateEvent
445 This event is sent just after the actual window associated with a wxWindow
446 object has been created.
448 Since it is derived from wxCommandEvent, the event propagates up
449 the window hierarchy.
451 @beginEventTable{wxWindowCreateEvent}
452 @event{EVT_WINDOW_CREATE(func)}:
453 Process a wxEVT_CREATE event.
459 @see @ref overview_eventhandling, wxWindowDestroyEvent
461 class wxWindowCreateEvent
: public wxCommandEvent
467 wxWindowCreateEvent(wxWindow
* win
= NULL
);
476 A paint event is sent when a window's contents needs to be repainted.
478 Please notice that in general it is impossible to change the drawing of a
479 standard control (such as wxButton) and so you shouldn't attempt to handle
480 paint events for them as even if it might work on some platforms, this is
481 inherently not portable and won't work everywhere.
484 Note that in a paint event handler, the application must always create a
485 wxPaintDC object, even if you do not use it. Otherwise, under MS Windows,
486 refreshing for this and other windows will go wrong.
489 void MyWindow::OnPaint(wxPaintEvent& event)
496 You can optimize painting by retrieving the rectangles that have been damaged
497 and only repainting these. The rectangles are in terms of the client area,
498 and are unscrolled, so you will need to do some calculations using the current
499 view position to obtain logical, scrolled units.
500 Here is an example of using the wxRegionIterator class:
502 // Called when window needs to be repainted.
503 void MyWindow::OnPaint(wxPaintEvent& event)
507 // Find Out where the window is scrolled to
508 int vbX,vbY; // Top left corner of client
509 GetViewStart(&vbX,&vbY);
511 int vX,vY,vW,vH; // Dimensions of client area in pixels
512 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
521 // Alternatively we can do this:
522 // wxRect rect(upd.GetRect());
524 // Repaint this rectangle
533 @beginEventTable{wxPaintEvent}
534 @event{EVT_PAINT(func)}:
535 Process a wxEVT_PAINT event.
541 @see @ref overview_eventhandling
543 class wxPaintEvent
: public wxEvent
549 wxPaintEvent(int id
= 0);
555 @class wxMaximizeEvent
558 An event being sent when a top level window is maximized. Notice that it is
559 not sent when the window is restored to its original size after it had been
560 maximized, only a normal wxSizeEvent is generated in this case.
562 @beginEventTable{wxMaximizeEvent}
563 @event{EVT_MAXIMIZE(func)}:
564 Process a wxEVT_MAXIMIZE event.
570 @see @ref overview_eventhandling, wxTopLevelWindow::Maximize,
571 wxTopLevelWindow::IsMaximized
573 class wxMaximizeEvent
: public wxEvent
577 Constructor. Only used by wxWidgets internally.
579 wxMaximizeEvent(int id
= 0);
585 @class wxUpdateUIEvent
588 This class is used for pseudo-events which are called by wxWidgets
589 to give an application the chance to update various user interface elements.
592 Without update UI events, an application has to work hard to check/uncheck,
593 enable/disable, show/hide, and set the text for elements such as menu items
594 and toolbar buttons. The code for doing this has to be mixed up with the code
595 that is invoked when an action is invoked for a menu item or button.
596 With update UI events, you define an event handler to look at the state of the
597 application and change UI elements accordingly. wxWidgets will call your member
598 functions in idle time, so you don't have to worry where to call this code.
599 In addition to being a clearer and more declarative method, it also means you don't
600 have to worry whether you're updating a toolbar or menubar identifier. The same
601 handler can update a menu item and toolbar button, if the identifier is the same.
602 Instead of directly manipulating the menu or button, you call functions in the event
603 object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a
604 call has been made, and which UI element to update.
605 These events will work for popup menus as well as menubars. Just before a menu is
606 popped up, wxMenu::UpdateUI is called to process any UI events for the window that
608 If you find that the overhead of UI update processing is affecting your application,
609 you can do one or both of the following:
610 @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED,
611 and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should
612 receive update events. No other windows will receive update events.
613 @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay
614 between updates. You may need to call wxWindow::UpdateWindowUI at critical points,
615 for example when a dialog is about to be shown, in case the user sees a slight
616 delay before windows are updated.
617 Note that although events are sent in idle time, defining a wxIdleEvent handler
618 for a window does not affect this because the events are sent from wxWindow::OnInternalIdle
619 which is always called in idle time.
620 wxWidgets tries to optimize update events on some platforms.
621 On Windows and GTK+, events for menubar items are only sent when the menu is about
622 to be shown, and not in idle time.
624 @beginEventTable{wxUpdateUIEvent}
625 @event{EVT_UPDATE_UI(id, func)}:
626 Process a wxEVT_UPDATE_UI event for the command with the given id.
627 @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}:
628 Process a wxEVT_UPDATE_UI event for any command with id included in the given range.
635 @see @ref overview_eventhandling
637 class wxUpdateUIEvent
: public wxCommandEvent
643 wxUpdateUIEvent(wxWindowID commandId
= 0);
646 Returns @true if it is appropriate to update (send UI update events to)
648 This function looks at the mode used (see wxUpdateUIEvent::SetMode),
649 the wxWS_EX_PROCESS_UI_UPDATES flag in @e window,
650 the time update events were last sent in idle time, and
651 the update interval, to determine whether events should be sent to
652 this window now. By default this will always return @true because
653 the update mode is initially wxUPDATE_UI_PROCESS_ALL and
654 the interval is set to 0; so update events will be sent as
655 often as possible. You can reduce the frequency that events
656 are sent by changing the mode and/or setting an update interval.
658 @see ResetUpdateTime(), SetUpdateInterval(),
661 static bool CanUpdate(wxWindow
* window
);
664 Check or uncheck the UI element.
666 void Check(bool check
);
669 Enable or disable the UI element.
671 void Enable(bool enable
);
674 Returns @true if the UI element should be checked.
676 bool GetChecked() const;
679 Returns @true if the UI element should be enabled.
681 bool GetEnabled() const;
684 Static function returning a value specifying how wxWidgets
685 will send update events: to all windows, or only to those which specify that
687 will process the events.
690 static wxUpdateUIMode
GetMode();
693 Returns @true if the application has called Check(). For wxWidgets internal use
696 bool GetSetChecked() const;
699 Returns @true if the application has called Enable(). For wxWidgets internal use
702 bool GetSetEnabled() const;
705 Returns @true if the application has called Show(). For wxWidgets internal use
708 bool GetSetShown() const;
711 Returns @true if the application has called SetText(). For wxWidgets internal
714 bool GetSetText() const;
717 Returns @true if the UI element should be shown.
719 bool GetShown() const;
722 Returns the text that should be set for the UI element.
724 wxString
GetText() const;
727 Returns the current interval between updates in milliseconds.
728 -1 disables updates, 0 updates as frequently as possible.
729 See SetUpdateInterval().
731 static long GetUpdateInterval();
734 Used internally to reset the last-updated time to the
735 current time. It is assumed that update events are
736 normally sent in idle time, so this is called at the end of
739 @see CanUpdate(), SetUpdateInterval(),
742 static void ResetUpdateTime();
745 Specify how wxWidgets will send update events: to
746 all windows, or only to those which specify that they
747 will process the events.
748 @a mode may be one of the following values.
749 The default is wxUPDATE_UI_PROCESS_ALL.
751 static void SetMode(wxUpdateUIMode mode
);
754 Sets the text for this UI element.
756 void SetText(const wxString
& text
);
759 Sets the interval between updates in milliseconds.
760 Set to -1 to disable updates, or to 0 to update as frequently as possible.
762 Use this to reduce the overhead of UI update events if your application
763 has a lot of windows. If you set the value to -1 or greater than 0,
764 you may also need to call wxWindow::UpdateWindowUI
765 at appropriate points in your application, such as when a dialog
766 is about to be shown.
768 static void SetUpdateInterval(long updateInterval
);
771 Show or hide the UI element.
773 void Show(bool show
);
779 @class wxClipboardTextEvent
782 This class represents the events generated by a control (typically a
783 wxTextCtrl but other windows can generate these events as
784 well) when its content gets copied or cut to, or pasted from the clipboard.
785 There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY,
786 wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE.
788 If any of these events is processed (without being skipped) by an event
789 handler, the corresponding operation doesn't take place which allows to
790 prevent the text from being copied from or pasted to a control. It is also
791 possible to examine the clipboard contents in the PASTE event handler and
792 transform it in some way before inserting in a control -- for example,
793 changing its case or removing invalid characters.
795 Finally notice that a CUT event is always preceded by the COPY event which
796 makes it possible to only process the latter if it doesn't matter if the
797 text was copied or cut.
799 @beginEventTable{wxClipboardTextEvent}
800 @event{EVT_TEXT_COPY(id, func)}:
801 Some or all of the controls content was copied to the clipboard.
802 @event{EVT_TEXT_CUT(id, func)}:
803 Some or all of the controls content was cut (i.e. copied and
805 @event{EVT_TEXT_PASTE(id, func)}:
806 Clipboard content was pasted into the control.
810 These events are currently only generated by wxTextCtrl under GTK+. They
811 are generated by all controls under Windows.
818 class wxClipboardTextEvent
: public wxCommandEvent
824 wxClipboardTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
833 This event class contains information about the events generated by the mouse:
834 they include mouse buttons press and release events and mouse move events.
836 All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
837 left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
838 @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
839 buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
840 can also be generated. Note that not all mice have even a middle button so a
841 portable application should avoid relying on the events from it (but the right
842 button click can be emulated using the left mouse button with the control key
843 under Mac platforms with a single button mouse).
845 For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
846 purposes, the mouse is considered to be inside the window if it is in the
847 window client area and not inside one of its children. In other words, the
848 parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
849 mouse leaves the window entirely but also when it enters one of its children.
851 @note Note that under Windows CE mouse enter and leave events are not natively
853 by the system but are generated by wxWidgets itself. This has several
854 drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
855 left the window and the state variables for it may have changed during this
858 @note Note the difference between methods like
859 wxMouseEvent::LeftDown and
860 wxMouseEvent::LeftIsDown: the former returns @true
861 when the event corresponds to the left mouse button click while the latter
862 returns @true if the left mouse button is currently being pressed. For
863 example, when the user is dragging the mouse you can use
864 wxMouseEvent::LeftIsDown to test
865 whether the left mouse button is (still) depressed. Also, by convention, if
866 wxMouseEvent::LeftDown returns @true,
867 wxMouseEvent::LeftIsDown will also return @true in
868 wxWidgets whatever the underlying GUI behaviour is (which is
869 platform-dependent). The same applies, of course, to other mouse buttons as
875 @see wxKeyEvent::CmdDown
877 class wxMouseEvent
: public wxEvent
881 Constructor. Valid event types are:
883 @b wxEVT_ENTER_WINDOW
884 @b wxEVT_LEAVE_WINDOW
890 @b wxEVT_MIDDLE_DCLICK
893 @b wxEVT_RIGHT_DCLICK
894 @b wxEVT_MOUSE_AUX1_DOWN
895 @b wxEVT_MOUSE_AUX1_UP
896 @b wxEVT_MOUSE_AUX1_DCLICK
897 @b wxEVT_MOUSE_AUX2_DOWN
898 @b wxEVT_MOUSE_AUX2_UP
899 @b wxEVT_MOUSE_AUX2_DCLICK
903 wxMouseEvent(wxEventType mouseEventType
= 0);
906 Returns @true if the Alt key was down at the time of the event.
908 bool AltDown() const;
911 Returns @true if the event was a first extra button double click.
913 bool Aux1DClick() const;
916 Returns @true if the first extra button mouse button changed to down.
918 bool Aux1Down() const;
921 Returns @true if the first extra button mouse button is currently down,
923 of the current event type.
925 bool Aux1IsDown() const;
928 Returns @true if the first extra button mouse button changed to up.
933 Returns @true if the event was a second extra button double click.
935 bool Aux2DClick() const;
938 Returns @true if the second extra button mouse button changed to down.
940 bool Aux2Down() const;
943 Returns @true if the second extra button mouse button is currently down,
945 of the current event type.
947 bool Aux2IsDown() const;
950 Returns @true if the second extra button mouse button changed to up.
955 Returns @true if the identified mouse button is changing state. Valid
956 values of @a button are:
960 check if left button was pressed
962 @c wxMOUSE_BTN_MIDDLE
964 check if middle button was pressed
968 check if right button was pressed
972 check if the first extra button was pressed
976 check if the second extra button was pressed
980 check if any button was pressed
982 bool Button(int button
) const;
985 If the argument is omitted, this returns @true if the event was a mouse
986 double click event. Otherwise the argument specifies which double click event
987 was generated (see Button() for the possible
990 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
993 If the argument is omitted, this returns @true if the event was a mouse
994 button down event. Otherwise the argument specifies which button-down event
995 was generated (see Button() for the possible
998 bool ButtonDown(int = wxMOUSE_BTN_ANY
) const;
1001 If the argument is omitted, this returns @true if the event was a mouse
1002 button up event. Otherwise the argument specifies which button-up event
1003 was generated (see Button() for the possible
1006 bool ButtonUp(int = wxMOUSE_BTN_ANY
) const;
1009 Same as MetaDown() under Mac, same as
1010 ControlDown() elsewhere.
1012 @see wxKeyEvent::CmdDown
1014 bool CmdDown() const;
1017 Returns @true if the control key was down at the time of the event.
1019 bool ControlDown() const;
1022 Returns @true if this was a dragging event (motion while a button is depressed).
1026 bool Dragging() const;
1029 Returns @true if the mouse was entering the window.
1032 bool Entering() const;
1035 Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
1036 if no button is involved (for mouse move, enter or leave event, for example).
1037 Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
1038 double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
1039 for the same events for the middle and the right buttons respectively.
1041 int GetButton() const;
1044 Returns the number of mouse clicks for this event: 1 for a simple click, 2
1045 for a double-click, 3 for a triple-click and so on.
1046 Currently this function is implemented only in wxMac and returns -1 for the
1047 other platforms (you can still distinguish simple clicks from double-clicks as
1048 they generate different kinds of events however).
1052 int GetClickCount() const;
1055 Returns the configured number of lines (or whatever) to be scrolled per
1056 wheel action. Defaults to three.
1058 int GetLinesPerAction() const;
1061 Returns the logical mouse position in pixels (i.e. translated according to the
1062 translation set for the DC, which usually indicates that the window has been
1065 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
1069 Sets *x and *y to the position at which the event occurred.
1070 Returns the physical mouse position in pixels.
1071 Note that if the mouse event has been artificially generated from a special
1072 keyboard combination (e.g. under Windows when the "menu'' key is pressed), the
1073 returned position is @c wxDefaultPosition.
1075 wxPoint
GetPosition() const;
1076 const void GetPosition(wxCoord
* x
, wxCoord
* y
) const;
1077 const void GetPosition(long* x
, long* y
) const;
1081 Get wheel delta, normally 120. This is the threshold for action to be
1082 taken, and one such action (for example, scrolling one increment)
1083 should occur for each delta.
1085 int GetWheelDelta() const;
1088 Get wheel rotation, positive or negative indicates direction of
1089 rotation. Current devices all send an event when rotation is at least
1090 +/-WheelDelta, but finer resolution devices can be created in the future.
1091 Because of this you shouldn't assume that one event is equal to 1 line, but you
1092 should be able to either do partial line scrolling or wait until several
1093 events accumulate before scrolling.
1095 int GetWheelRotation() const;
1098 Returns X coordinate of the physical mouse event position.
1100 wxCoord
GetX() const;
1103 Returns Y coordinate of the physical mouse event position.
1105 wxCoord
GetY() const;
1108 Returns @true if the event was a mouse button event (not necessarily a button
1110 that may be tested using @e ButtonDown).
1112 bool IsButton() const;
1115 Returns @true if the system has been setup to do page scrolling with
1116 the mouse wheel instead of line scrolling.
1118 bool IsPageScroll() const;
1121 Returns @true if the mouse was leaving the window.
1122 See also Entering().
1124 bool Leaving() const;
1127 Returns @true if the event was a left double click.
1129 bool LeftDClick() const;
1132 Returns @true if the left mouse button changed to down.
1134 bool LeftDown() const;
1137 Returns @true if the left mouse button is currently down, independent
1138 of the current event type.
1139 Please notice that it is not the same as
1140 LeftDown() which returns @true if the event was
1141 generated by the left mouse button being pressed. Rather, it simply describes
1142 the state of the left mouse button at the time when the event was generated
1143 (so while it will be @true for a left click event, it can also be @true for
1144 a right click if it happened while the left mouse button was pressed).
1145 This event is usually used in the mouse event handlers which process "move
1146 mouse" messages to determine whether the user is (still) dragging the mouse.
1148 bool LeftIsDown() const;
1151 Returns @true if the left mouse button changed to up.
1153 bool LeftUp() const;
1156 Returns @true if the Meta key was down at the time of the event.
1158 bool MetaDown() const;
1161 Returns @true if the event was a middle double click.
1163 bool MiddleDClick() const;
1166 Returns @true if the middle mouse button changed to down.
1168 bool MiddleDown() const;
1171 Returns @true if the middle mouse button is currently down, independent
1172 of the current event type.
1174 bool MiddleIsDown() const;
1177 Returns @true if the middle mouse button changed to up.
1179 bool MiddleUp() const;
1182 Returns @true if this was a motion event and no mouse buttons were pressed.
1183 If any mouse button is held pressed, then this method returns @false and
1184 Dragging() returns @true.
1186 bool Moving() const;
1189 Returns @true if the event was a right double click.
1191 bool RightDClick() const;
1194 Returns @true if the right mouse button changed to down.
1196 bool RightDown() const;
1199 Returns @true if the right mouse button is currently down, independent
1200 of the current event type.
1202 bool RightIsDown() const;
1205 Returns @true if the right mouse button changed to up.
1207 bool RightUp() const;
1210 Returns @true if the shift key was down at the time of the event.
1212 bool ShiftDown() const;
1216 @true if the Alt key is pressed down.
1222 @true if control key is pressed down.
1228 @true if the left mouse button is currently pressed down.
1233 int m_linesPerAction
1234 The configured number of lines (or whatever) to be scrolled per wheel
1241 @true if the Meta key is pressed down.
1247 @true if the middle mouse button is currently pressed down.
1253 @true if the right mouse button is currently pressed down.
1259 @true if shift is pressed down.
1265 The wheel delta, normally 120.
1271 The distance the mouse wheel is rotated.
1277 X-coordinate of the event.
1283 Y-coordinate of the event.
1290 @class wxDropFilesEvent
1293 This class is used for drop files events, that is, when files have been dropped
1294 onto the window. This functionality is currently only available under Windows.
1295 The window must have previously been enabled for dropping by calling
1296 wxWindow::DragAcceptFiles.
1298 Important note: this is a separate implementation to the more general
1299 drag and drop implementation documented here(). It uses the
1300 older, Windows message-based approach of dropping files.
1305 @see @ref overview_eventhandling
1307 class wxDropFilesEvent
: public wxEvent
1313 wxDropFilesEvent(wxEventType id
= 0, int noFiles
= 0,
1314 wxString
* files
= NULL
);
1317 Returns an array of filenames.
1319 wxString
* GetFiles() const;
1322 Returns the number of files dropped.
1324 int GetNumberOfFiles() const;
1327 Returns the position at which the files were dropped.
1328 Returns an array of filenames.
1330 wxPoint
GetPosition() const;
1334 An array of filenames.
1340 The number of files dropped.
1346 The point at which the drop took place.
1353 @class wxCommandEvent
1356 This event class contains information about command events, which originate
1358 simple controls. More complex controls, such as wxTreeCtrl, have separate
1359 command event classes.
1364 class wxCommandEvent
: public wxEvent
1370 wxCommandEvent(wxEventType commandEventType
= 0, int id
= 0);
1373 Deprecated, use IsChecked() instead.
1375 bool Checked() const;
1378 Returns client data pointer for a listbox or choice selection event
1379 (not valid for a deselection).
1381 void* GetClientData() const;
1384 Returns client object pointer for a listbox or choice selection event
1385 (not valid for a deselection).
1387 wxClientData
* GetClientObject() const;
1390 Returns extra information dependant on the event objects type.
1391 If the event comes from a listbox selection, it is a boolean
1392 determining whether the event was a selection (@true) or a
1393 deselection (@false). A listbox deselection only occurs for
1394 multiple-selection boxes, and in this case the index and string values
1395 are indeterminate and the listbox must be examined by the application.
1397 long GetExtraLong() const;
1400 Returns the integer identifier corresponding to a listbox, choice or
1401 radiobox selection (only if the event was a selection, not a
1402 deselection), or a boolean value representing the value of a checkbox.
1407 Returns item index for a listbox or choice selection event (not valid for
1410 int GetSelection() const;
1413 Returns item string for a listbox or choice selection event (not valid for
1416 wxString
GetString() const;
1419 This method can be used with checkbox and menu events: for the checkboxes, the
1420 method returns @true for a selection event and @false for a
1421 deselection one. For the menu events, this method indicates if the menu item
1422 just has become checked or unchecked (and thus only makes sense for checkable
1424 Notice that this method can not be used with
1425 wxCheckListBox currently.
1427 bool IsChecked() const;
1430 For a listbox or similar event, returns @true if it is a selection, @false if it
1433 bool IsSelection() const;
1436 Sets the client data for this event.
1438 void SetClientData(void* clientData
);
1441 Sets the client object for this event. The client object is not owned by the
1443 object and the event object will not delete the client object in its destructor.
1444 The client object must be owned and deleted by another object (e.g. a control)
1445 that has longer life time than the event object.
1447 void SetClientObject(wxClientData
* clientObject
);
1450 Sets the @b m_extraLong member.
1452 void SetExtraLong(long extraLong
);
1455 Sets the @b m_commandInt member.
1457 void SetInt(int intCommand
);
1460 Sets the @b m_commandString member.
1462 void SetString(const wxString
& string
);
1468 @class wxActivateEvent
1471 An activate event is sent when a window or application is being activated
1477 @see @ref overview_eventhandling, wxApp::IsActive
1479 class wxActivateEvent
: public wxEvent
1485 wxActivateEvent(wxEventType eventType
= wxEVT_NULL
, bool active
= true,
1489 Returns @true if the application or window is being activated, @false otherwise.
1491 bool GetActive() const;
1497 @class wxContextMenuEvent
1500 This class is used for context menu events, sent to give
1501 the application a chance to show a context (popup) menu.
1503 Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
1504 means that the event originated
1505 from a keyboard context button event, and you should compute a suitable
1507 for example by calling wxGetMousePosition().
1509 When a keyboard context menu button is pressed on Windows, a right-click event
1510 with default position is sent first,
1511 and if this event is not processed, the context menu event is sent. So if you
1512 process mouse events and you find your context menu event handler
1513 is not being called, you could call wxEvent::Skip for mouse right-down events.
1518 @see @ref overview_wxcommandevent "Command events", @ref
1519 overview_eventhandling
1521 class wxContextMenuEvent
: public wxCommandEvent
1527 wxContextMenuEvent(wxEventType id
= 0, int id
= 0,
1528 const wxPoint
& pos
= wxDefaultPosition
);
1531 Returns the position in screen coordinates at which the menu should be shown.
1532 Use wxWindow::ScreenToClient to
1533 convert to client coordinates. You can also omit a position from
1534 wxWindow::PopupMenu in order to use
1535 the current mouse pointer position.
1536 If the event originated from a keyboard event, the value returned from this
1537 function will be wxDefaultPosition.
1539 const wxPoint
& GetPosition() const;
1542 Sets the position at which the menu should be shown.
1544 void SetPosition(const wxPoint
& point
);
1553 An erase event is sent when a window's background needs to be repainted.
1555 On some platforms, such as GTK+, this event is simulated (simply generated just
1557 paint event) and may cause flicker. It is therefore recommended that
1558 you set the text background colour explicitly in order to prevent flicker.
1559 The default background colour under GTK+ is grey.
1561 To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
1564 You must call wxEraseEvent::GetDC and use the returned device context if it is
1566 If it is @NULL, create your own temporary wxClientDC object.
1571 @see @ref overview_eventhandling
1573 class wxEraseEvent
: public wxEvent
1579 wxEraseEvent(int id
= 0, wxDC
* dc
= NULL
);
1582 Returns the device context associated with the erase event to draw on.
1584 wxDC
* GetDC() const;
1593 A focus event is sent when a window's focus changes. The window losing focus
1594 receives a "kill focus'' event while the window gaining it gets a "set
1597 Notice that the set focus event happens both when the user gives focus to the
1598 window (whether using the mouse or keyboard) and when it is done from the
1599 program itself using wxWindow::SetFocus.
1604 @see @ref overview_eventhandling
1606 class wxFocusEvent
: public wxEvent
1612 wxFocusEvent(wxEventType eventType
= 0, int id
= 0);
1615 Returns the window associated with this event, that is the window which had the
1616 focus before for the @c wxEVT_SET_FOCUS event and the window which is
1617 going to receive focus for the @c wxEVT_KILL_FOCUS one.
1618 Warning: the window pointer may be @NULL!
1625 @class wxChildFocusEvent
1628 A child focus event is sent to a (parent-)window when one of its child windows
1630 so that the window could restore the focus back to its corresponding child
1631 if it loses it now and regains later.
1633 Notice that child window is the direct child of the window receiving event.
1634 Use wxWindow::FindFocus to retreive the window which is actually getting focus.
1639 @see @ref overview_eventhandling
1641 class wxChildFocusEvent
: public wxCommandEvent
1648 The direct child which is (or which contains the window which is) receiving
1651 wxChildFocusEvent(wxWindow
* win
= NULL
);
1654 Returns the direct child which receives the focus, or a (grand-)parent of the
1655 control receiving the focus.
1656 To get the actually focused control use wxWindow::FindFocus.
1663 @class wxMouseCaptureLostEvent
1666 An mouse capture lost event is sent to a window that obtained mouse capture,
1667 which was subsequently loss due to "external" event, for example when a dialog
1668 box is shown or if another application captures the mouse.
1670 If this happens, this event is sent to all windows that are on capture stack
1671 (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
1672 not sent if the capture changes because of a call to CaptureMouse or
1675 This event is currently emitted under Windows only.
1680 @see wxMouseCaptureChangedEvent, @ref overview_eventhandling,
1681 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
1683 class wxMouseCaptureLostEvent
: public wxEvent
1689 wxMouseCaptureLostEvent(wxWindowID windowId
= 0);
1695 @class wxNotifyEvent
1698 This class is not used by the event handlers by itself, but is a base class
1699 for other event classes (such as wxNotebookEvent).
1701 It (or an object of a derived class) is sent when the controls state is being
1702 changed and allows the program to wxNotifyEvent::Veto this
1703 change if it wants to prevent it from happening.
1708 @see wxNotebookEvent
1710 class wxNotifyEvent
: public wxCommandEvent
1714 Constructor (used internally by wxWidgets only).
1716 wxNotifyEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
1719 This is the opposite of Veto(): it explicitly
1720 allows the event to be processed. For most events it is not necessary to call
1721 this method as the events are allowed anyhow but some are forbidden by default
1722 (this will be mentioned in the corresponding event description).
1727 Returns @true if the change is allowed (Veto()
1728 hasn't been called) or @false otherwise (if it was).
1730 bool IsAllowed() const;
1733 Prevents the change announced by this event from happening.
1734 It is in general a good idea to notify the user about the reasons for vetoing
1735 the change because otherwise the applications behaviour (which just refuses to
1736 do what the user wants) might be quite surprising.
1747 A help event is sent when the user has requested context-sensitive help.
1748 This can either be caused by the application requesting
1749 context-sensitive help mode via wxContextHelp, or
1750 (on MS Windows) by the system generating a WM_HELP message when the user
1751 pressed F1 or clicked
1752 on the query button in a dialog caption.
1754 A help event is sent to the window that the user clicked on, and is propagated
1756 window hierarchy until the event is processed or there are no more event
1758 The application should call wxEvent::GetId to check the identity of the
1760 and then either show some suitable help or call wxEvent::Skip if the identifier
1762 Calling Skip is important because it allows wxWidgets to generate further
1763 events for ancestors
1764 of the clicked-on window. Otherwise it would be impossible to show help for
1766 since processing would stop after the first window found.
1771 @see wxContextHelp, wxDialog, @ref overview_eventhandling
1773 class wxHelpEvent
: public wxCommandEvent
1776 // how was this help event generated?
1779 Origin_Unknown
, // unrecognized event source
1780 Origin_Keyboard
, // event generated from F1 key press
1781 Origin_HelpButton
// event from [?] button on the title bar (Windows)
1787 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
1788 wxWindowID winid
= 0,
1789 const wxPoint
& pt
= wxDefaultPosition
,
1790 Origin origin
= Origin_Unknown
);
1793 Returns the origin of the help event which is one of the following values:
1797 Unrecognized event source.
1801 Event generated by @c F1 key press.
1803 @b Origin_HelpButton
1806 wxContextHelp or using the "?" title bur button under
1809 The application may handle events generated using the keyboard or mouse
1810 differently, e.g. by using wxGetMousePosition()
1811 for the mouse events.
1815 Origin
GetOrigin() const;
1818 Returns the left-click position of the mouse, in screen coordinates. This allows
1819 the application to position the help appropriately.
1821 const wxPoint
& GetPosition() const;
1824 Set the help event origin, only used internally by wxWidgets normally.
1828 void SetOrigin(Origin
);
1831 Sets the left-click position of the mouse, in screen coordinates.
1833 void SetPosition(const wxPoint
& pt
);
1839 @class wxScrollEvent
1842 A scroll event holds information about events sent from stand-alone
1843 scrollbars() and sliders(). Note that
1844 starting from wxWidgets 2.1, scrolled windows send the
1845 wxScrollWinEvent which does not derive from
1846 wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
1847 events and use the event table macros mentioned below only for the
1848 scrollbar-like controls.
1853 @see wxScrollBar, wxSlider, wxSpinButton, , wxScrollWinEvent, @ref
1854 overview_eventhandling
1856 class wxScrollEvent
: public wxCommandEvent
1862 wxScrollEvent(wxEventType commandType
= 0, int id
= 0, int pos
= 0,
1863 int orientation
= 0);
1866 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
1869 int GetOrientation() const;
1872 Returns the position of the scrollbar.
1874 int GetPosition() const;
1883 This class is used for idle events, which are generated when the system becomes
1884 idle. Note that, unless you do something specifically, the idle events are not
1885 sent if the system remains idle once it has become it, e.g. only a single idle
1886 event will be generated until something else resulting in more normal events
1887 happens and only then is the next idle event sent again. If you need to ensure
1888 a continuous stream of idle events, you can either use
1889 wxIdleEvent::RequestMore method in your handler or call
1890 wxWakeUpIdle() periodically (for example from timer
1891 event), but note that both of these approaches (and especially the first one)
1892 increase the system load and so should be avoided if possible.
1894 By default, idle events are sent to all windows (and also
1895 wxApp, as usual). If this is causing a significant
1896 overhead in your application, you can call wxIdleEvent::SetMode with
1897 the value wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra
1898 window style for every window which should receive idle events.
1903 @see @ref overview_eventhandling, wxUpdateUIEvent,
1904 wxWindow::OnInternalIdle
1906 class wxIdleEvent
: public wxEvent
1915 Returns @true if it is appropriate to send idle events to
1917 This function looks at the mode used (see wxIdleEvent::SetMode),
1918 and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle
1919 events should be sent to
1920 this window now. By default this will always return @true because
1921 the update mode is initially wxIDLE_PROCESS_ALL. You can change the mode
1922 to only send idle events to windows with the wxWS_EX_PROCESS_IDLE extra window
1927 static bool CanSend(wxWindow
* window
);
1930 Static function returning a value specifying how wxWidgets
1931 will send idle events: to all windows, or only to those which specify that they
1932 will process the events.
1935 static wxIdleMode
GetMode();
1938 Returns @true if the OnIdle function processing this event requested more
1943 bool MoreRequested() const;
1946 Tells wxWidgets that more processing is required. This function can be called
1948 handler for a window or window event handler to indicate that wxApp::OnIdle
1950 forward the OnIdle event once more to the application windows. If no window
1952 during OnIdle, then the application will remain in a passive event loop (not
1953 calling OnIdle) until a
1954 new event is posted to the application by the windowing system.
1956 @see MoreRequested()
1958 void RequestMore(bool needMore
= true);
1961 Static function for specifying how wxWidgets will send idle events: to
1962 all windows, or only to those which specify that they
1963 will process the events.
1964 @a mode can be one of the following values.
1965 The default is wxIDLE_PROCESS_ALL.
1967 static void SetMode(wxIdleMode mode
);
1973 @class wxInitDialogEvent
1976 A wxInitDialogEvent is sent as a dialog or panel is being initialised.
1977 Handlers for this event can transfer data to the window.
1978 The default handler calls wxWindow::TransferDataToWindow.
1983 @see @ref overview_eventhandling
1985 class wxInitDialogEvent
: public wxEvent
1991 wxInitDialogEvent(int id
= 0);
1997 @class wxWindowDestroyEvent
2000 This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a
2001 window is destroyed.
2003 When a class derived from wxWindow is destroyed its destructor will have
2004 already run by the time this event is sent. Therefore this event will not
2005 usually be received at all.
2007 To receive this event wxEvtHandler::Connect
2008 must be used (using an event table macro will not work). Since it is
2009 received after the destructor has run, an object should not handle its
2010 own wxWindowDestroyEvent, but it can be used to get notification of the
2011 destruction of another window.
2016 @see @ref overview_eventhandling, wxWindowCreateEvent
2018 class wxWindowDestroyEvent
: public wxCommandEvent
2024 wxWindowDestroyEvent(wxWindow
* win
= NULL
);
2030 @class wxNavigationKeyEvent
2033 This event class contains information about navigation events,
2034 generated by navigation keys such as tab and page down.
2036 This event is mainly used by wxWidgets implementations. A
2037 wxNavigationKeyEvent handler is automatically provided by wxWidgets
2038 when you make a class into a control container with the macro
2039 WX_DECLARE_CONTROL_CONTAINER.
2044 @see wxWindow::Navigate, wxWindow::NavigateIn
2046 class wxNavigationKeyEvent
2053 wxNavigationKeyEvent();
2054 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
);
2058 Returns the child that has the focus, or @NULL.
2060 wxWindow
* GetCurrentFocus() const;
2063 Returns @true if the navigation was in the forward direction.
2065 bool GetDirection() const;
2068 Returns @true if the navigation event was from a tab key. This is required
2069 for proper navigation over radio buttons.
2071 bool IsFromTab() const;
2074 Returns @true if the navigation event represents a window change (for
2075 example, from Ctrl-Page Down
2078 bool IsWindowChange() const;
2081 Sets the current focus window member.
2083 void SetCurrentFocus(wxWindow
* currentFocus
);
2086 Sets the direction to forward if @a direction is @true, or backward if @c
2089 void SetDirection(bool direction
);
2094 void SetFlags(long flags
);
2097 Marks the navigation event as from a tab key.
2099 void SetFromTab(bool fromTab
);
2102 Marks the event as a window change event.
2104 void SetWindowChange(bool windowChange
);
2110 @class wxMouseCaptureChangedEvent
2113 An mouse capture changed event is sent to a window that loses its
2114 mouse capture. This is called even if wxWindow::ReleaseCapture
2115 was called by the application code. Handling this event allows
2116 an application to cater for unexpected capture releases which
2117 might otherwise confuse mouse handling code.
2119 This event is implemented under Windows only.
2124 @see wxMouseCaptureLostEvent, @ref overview_eventhandling,
2125 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2127 class wxMouseCaptureChangedEvent
: public wxEvent
2133 wxMouseCaptureChangedEvent(wxWindowID windowId
= 0,
2134 wxWindow
* gainedCapture
= NULL
);
2137 Returns the window that gained the capture, or @NULL if it was a non-wxWidgets
2140 wxWindow
* GetCapturedWindow() const;
2149 This event class contains information about window and session close events.
2151 The handler function for EVT_CLOSE is called when the user has tried to close a
2153 or dialog box using the window manager (X) or system menu (Windows). It can
2154 also be invoked by the application itself programmatically, for example by
2155 calling the wxWindow::Close function.
2157 You should check whether the application is forcing the deletion of the window
2158 using wxCloseEvent::CanVeto. If this is @false,
2159 you @e must destroy the window using wxWindow::Destroy.
2160 If the return value is @true, it is up to you whether you respond by destroying
2163 If you don't destroy the window, you should call wxCloseEvent::Veto to
2164 let the calling code know that you did not destroy the window. This allows the
2165 wxWindow::Close function
2166 to return @true or @false depending on whether the close instruction was
2172 @see wxWindow::Close, @ref overview_windowdeletionoverview "Window deletion
2175 class wxCloseEvent
: public wxEvent
2181 wxCloseEvent(wxEventType commandEventType
= 0, int id
= 0);
2184 Returns @true if you can veto a system shutdown or a window close event.
2185 Vetoing a window close event is not possible if the calling code wishes to
2186 force the application to exit, and so this function must be called to check
2189 bool CanVeto() const;
2192 Returns @true if the user is just logging off or @false if the system is
2193 shutting down. This method can only be called for end session and query end
2194 session events, it doesn't make sense for close window event.
2196 bool GetLoggingOff() const;
2199 Sets the 'can veto' flag.
2201 void SetCanVeto(bool canVeto
);
2204 Sets the 'force' flag.
2206 void SetForce(bool force
) const;
2209 Sets the 'logging off' flag.
2211 void SetLoggingOff(bool loggingOff
);
2214 Call this from your event handler to veto a system shutdown or to signal
2215 to the calling application that a window close did not happen.
2216 You can only veto a shutdown if CanVeto() returns
2219 void Veto(bool veto
= true);
2228 This class is used for a variety of menu-related events. Note that
2229 these do not include menu command events, which are
2230 handled using wxCommandEvent objects.
2232 The default handler for wxEVT_MENU_HIGHLIGHT displays help
2233 text in the first field of the status bar.
2238 @see @ref overview_wxcommandevent "Command events", @ref
2239 overview_eventhandling
2241 class wxMenuEvent
: public wxEvent
2247 wxMenuEvent(wxEventType id
= 0, int id
= 0, wxMenu
* menu
= NULL
);
2250 Returns the menu which is being opened or closed. This method should only be
2251 used with the @c OPEN and @c CLOSE events and even for them the
2252 returned pointer may be @NULL in some ports.
2254 wxMenu
* GetMenu() const;
2257 Returns the menu identifier associated with the event. This method should be
2258 only used with the @c HIGHLIGHT events.
2260 int GetMenuId() const;
2263 Returns @true if the menu which is being opened or closed is a popup menu,
2264 @false if it is a normal one.
2265 This method should only be used with the @c OPEN and @c CLOSE events.
2267 bool IsPopup() const;
2273 @class wxEventBlocker
2276 This class is a special event handler which allows to discard
2277 any event (or a set of event types) directed to a specific window.
2283 // block all events directed to this window while
2284 // we do the 1000 FuncWhichSendsEvents() calls
2285 wxEventBlocker blocker(this);
2287 for ( int i = 0; i 1000; i++ )
2288 FuncWhichSendsEvents(i);
2290 } // ~wxEventBlocker called, old event handler is restored
2292 // the event generated by this call will be processed
2293 FuncWhichSendsEvents(0)
2299 @see @ref overview_eventhandling, wxEvtHandler
2301 class wxEventBlocker
: public wxEvtHandler
2305 Constructs the blocker for the given window and for the given event type.
2306 If @a type is @c wxEVT_ANY, then all events for that window are
2307 blocked. You can call Block() after creation to
2308 add other event types to the list of events to block.
2309 Note that the @a win window @b must remain alive until the
2310 wxEventBlocker object destruction.
2312 wxEventBlocker(wxWindow
* win
, wxEventType
= -0x000000001);
2315 Destructor. The blocker will remove itself from the chain of event handlers for
2316 the window provided in the constructor, thus restoring normal processing of
2319 virtual ~wxEventBlocker();
2322 Adds to the list of event types which should be blocked the given @e eventType.
2324 void Block(wxEventType eventType
);
2333 A class that can handle events from the windowing system.
2334 wxWindow (and therefore all window classes) are derived from
2337 When events are received, wxEvtHandler invokes the method listed in the
2338 event table using itself as the object. When using multiple inheritance
2339 it is imperative that the wxEvtHandler(-derived) class be the first
2340 class inherited such that the "this" pointer for the overall object
2341 will be identical to the "this" pointer for the wxEvtHandler portion.
2346 @see @ref overview_eventhandling
2348 class wxEvtHandler
: public wxObject
2357 Destructor. If the handler is part of a chain, the destructor will
2358 unlink itself and restore the previous and next handlers so that they point to
2361 virtual ~wxEvtHandler();
2364 This function posts an event to be processed later.
2367 Event to add to process queue.
2369 @remarks The difference between sending an event (using the ProcessEvent
2370 method) and posting it is that in the first case the
2371 event is processed before the function returns, while
2372 in the second case, the function returns immediately
2373 and the event will be processed sometime later (usually
2374 during the next event loop iteration).
2376 virtual void AddPendingEvent(const wxEvent
& event
);
2380 Connects the given function dynamically with the event handler, id and event
2382 is an alternative to the use of static event tables. See the 'event' or the old
2383 'dynamic' sample for usage.
2386 The identifier (or first of the identifier range) to be
2387 associated with the event handler function. For the version not taking this
2388 argument, it defaults to wxID_ANY.
2390 The second part of the identifier range to be associated with the event
2393 The event type to be associated with this event handler.
2395 The event handler function. Note that this function should
2396 be explicitly converted to the correct type which can be done using a macro
2397 called wxFooEventHandler for the handler for any wxFooEvent.
2399 Data to be associated with the event table entry.
2401 Object whose member function should be called. If this is @NULL,
2404 void Connect(int id
, int lastId
, wxEventType eventType
,
2405 wxObjectEventFunction function
,
2406 wxObject
* userData
= NULL
,
2407 wxEvtHandler
* eventSink
= NULL
);
2408 void Connect(int id
, wxEventType eventType
,
2409 wxObjectEventFunction function
,
2410 wxObject
* userData
= NULL
,
2411 wxEvtHandler
* eventSink
= NULL
);
2412 void Connect(wxEventType eventType
,
2413 wxObjectEventFunction function
,
2414 wxObject
* userData
= NULL
,
2415 wxEvtHandler
* eventSink
= NULL
);
2420 Disconnects the given function dynamically from the event handler, using the
2422 parameters as search criteria and returning @true if a matching function has been
2423 found and removed. This method can only disconnect functions which have been
2425 using the Connect() method. There is no way
2426 to disconnect functions connected using the (static) event tables.
2429 The identifier (or first of the identifier range) associated with the event
2432 The second part of the identifier range associated with the event handler
2435 The event type associated with this event handler.
2437 The event handler function.
2439 Data associated with the event table entry.
2441 Object whose member function should be called.
2443 bool Disconnect(wxEventType eventType
= wxEVT_NULL
,
2444 wxObjectEventFunction function
= NULL
,
2445 wxObject
* userData
= NULL
,
2446 wxEvtHandler
* eventSink
= NULL
);
2447 bool Disconnect(int id
= wxID_ANY
,
2448 wxEventType eventType
= wxEVT_NULL
,
2449 wxObjectEventFunction function
= NULL
,
2450 wxObject
* userData
= NULL
,
2451 wxEvtHandler
* eventSink
= NULL
);
2452 bool Disconnect(int id
, int lastId
= wxID_ANY
,
2453 wxEventType eventType
= wxEVT_NULL
,
2454 wxObjectEventFunction function
= NULL
,
2455 wxObject
* userData
= NULL
,
2456 wxEvtHandler
* eventSink
= NULL
);
2460 Gets user-supplied client data.
2462 @remarks Normally, any extra data the programmer wishes to associate with
2463 the object should be made available by deriving a new
2464 class with new data members.
2466 @see SetClientData()
2468 void* GetClientData() const;
2471 Get a pointer to the user-supplied client data object.
2473 @see SetClientObject(), wxClientData
2475 wxClientData
* GetClientObject() const;
2478 Returns @true if the event handler is enabled, @false otherwise.
2480 @see SetEvtHandlerEnabled()
2482 bool GetEvtHandlerEnabled() const;
2485 Gets the pointer to the next handler in the chain.
2487 @see SetNextHandler(), GetPreviousHandler(),
2488 SetPreviousHandler(), wxWindow::PushEventHandler,
2489 wxWindow::PopEventHandler
2491 wxEvtHandler
* GetNextHandler() const;
2494 Gets the pointer to the previous handler in the chain.
2496 @see SetPreviousHandler(), GetNextHandler(),
2497 SetNextHandler(), wxWindow::PushEventHandler,
2498 wxWindow::PopEventHandler
2500 wxEvtHandler
* GetPreviousHandler() const;
2503 Processes an event, searching event tables and calling zero or more suitable
2504 event handler function(s).
2509 @returns @true if a suitable event handler function was found and
2510 executed, and the function did not call wxEvent::Skip.
2512 @remarks Normally, your application would not call this function: it is
2513 called in the wxWidgets implementation to dispatch
2514 incoming user interface events to the framework (and
2517 @see SearchEventTable()
2519 virtual bool ProcessEvent(wxEvent
& event
);
2522 Processes an event by calling ProcessEvent()
2523 and handles any exceptions that occur in the process. If an exception is
2524 thrown in event handler, wxApp::OnExceptionInMainLoop
2530 @returns @true if the event was processed, @false if no handler was found
2531 or an exception was thrown.
2533 @see wxWindow::HandleWindowEvent
2535 bool SafelyProcessEvent(wxEvent
& event
);
2538 Searches the event table, executing an event handler function if an appropriate
2543 Event table to be searched.
2545 Event to be matched against an event table entry.
2547 @returns @true if a suitable event handler function was found and
2548 executed, and the function did not call wxEvent::Skip.
2550 @remarks This function looks through the object's event table and tries
2551 to find an entry that will match the event.
2555 virtual bool SearchEventTable(wxEventTable
& table
,
2559 Sets user-supplied client data.
2562 Data to be associated with the event handler.
2564 @remarks Normally, any extra data the programmer wishes to associate with
2565 the object should be made available by deriving a new
2566 class with new data members. You must not call this
2567 method and SetClientObject on the same class - only one
2570 @see GetClientData()
2572 void SetClientData(void* data
);
2575 Set the client data object. Any previous object will be deleted.
2577 @see GetClientObject(), wxClientData
2579 void SetClientObject(wxClientData
* data
);
2582 Enables or disables the event handler.
2585 @true if the event handler is to be enabled, @false if it is to be disabled.
2587 @remarks You can use this function to avoid having to remove the event
2588 handler from the chain, for example when implementing a
2589 dialog editor and changing from edit to test mode.
2591 @see GetEvtHandlerEnabled()
2593 void SetEvtHandlerEnabled(bool enabled
);
2596 Sets the pointer to the next handler.
2599 Event handler to be set as the next handler.
2601 @see GetNextHandler(), SetPreviousHandler(),
2602 GetPreviousHandler(), wxWindow::PushEventHandler,
2603 wxWindow::PopEventHandler
2605 void SetNextHandler(wxEvtHandler
* handler
);
2608 Sets the pointer to the previous handler.
2611 Event handler to be set as the previous handler.
2613 void SetPreviousHandler(wxEvtHandler
* handler
);
2619 @class wxIconizeEvent
2622 An event being sent when the frame is iconized (minimized) or restored.
2624 Currently only wxMSW and wxGTK generate such events.
2629 @see @ref overview_eventhandling, wxTopLevelWindow::Iconize,
2630 wxTopLevelWindow::IsIconized
2632 class wxIconizeEvent
: public wxEvent
2638 wxIconizeEvent(int id
= 0, bool iconized
= true);
2641 Returns @true if the frame has been iconized, @false if it has been
2644 bool Iconized() const;
2653 A move event holds information about move change events.
2658 @see wxPoint, @ref overview_eventhandling
2660 class wxMoveEvent
: public wxEvent
2666 wxMoveEvent(const wxPoint
& pt
, int id
= 0);
2669 Returns the position of the window generating the move change event.
2671 wxPoint
GetPosition() const;
2680 An event is a structure holding information about an event passed to a
2681 callback or member function. @b wxEvent used to be a multipurpose
2682 event object, and is an abstract base class for other event classes (see below).
2684 For more information about events, see the @ref overview_eventhandling.
2686 @b wxPerl note: In wxPerl custom event classes should be derived from
2687 @c Wx::PlEvent and @c Wx::PlCommandEvent.
2692 @see wxCommandEvent, wxMouseEvent
2694 class wxEvent
: public wxObject
2698 Constructor. Should not need to be used directly by an application.
2700 wxEvent(int id
= 0, wxEventType eventType
= wxEVT_NULL
);
2703 Returns a copy of the event.
2704 Any event that is posted to the wxWidgets event system for later action (via
2705 wxEvtHandler::AddPendingEvent or
2706 wxPostEvent()) must implement this method. All wxWidgets
2707 events fully implement this method, but any derived events implemented by the
2708 user should also implement this method just in case they (or some event
2709 derived from them) are ever posted.
2710 All wxWidgets events implement a copy constructor, so the easiest way of
2711 implementing the Clone function is to implement a copy constructor for
2712 a new event (call it MyEvent) and then define the Clone function like this:
2714 virtual wxEvent
* Clone() const = 0;
2717 Returns the object (usually a window) associated with the
2720 wxObject
* GetEventObject() const;
2723 Returns the identifier of the given event type,
2724 such as @c wxEVT_COMMAND_BUTTON_CLICKED.
2726 wxEventType
GetEventType() const;
2729 Returns the identifier associated with this event, such as a button command id.
2734 Returns @true if the event handler should be skipped, @false otherwise.
2736 bool GetSkipped() const;
2739 Gets the timestamp for the event. The timestamp is the time in milliseconds
2740 since some fixed moment (not necessarily the standard Unix Epoch, so
2741 only differences between the timestamps and not their absolute values usually
2744 long GetTimestamp() const;
2747 Returns @true if the event is or is derived from
2748 wxCommandEvent else it returns @false.
2749 Note: Exists only for optimization purposes.
2751 bool IsCommandEvent() const;
2754 Sets the propagation level to the given value (for example returned from an
2755 earlier call to wxEvent::StopPropagation).
2757 void ResumePropagation(int propagationLevel
);
2760 Sets the originating object.
2762 void SetEventObject(wxObject
* object
);
2765 Sets the event type.
2767 void SetEventType(wxEventType type
);
2770 Sets the identifier associated with this event, such as a button command id.
2775 Sets the timestamp for the event.
2777 void SetTimestamp(long = 0);
2780 Test if this event should be propagated or not, i.e. if the propagation level
2781 is currently greater than 0.
2783 bool ShouldPropagate() const;
2786 This method can be used inside an event handler to control whether further
2787 event handlers bound to this event will be called after the current one
2788 returns. Without Skip() (or equivalently if Skip(@false) is used),
2789 the event will not be processed any more. If Skip(@true) is called, the event
2790 processing system continues searching for a further handler function for this
2791 event, even though it has been processed already in the current handler.
2792 In general, it is recommended to skip all non-command events to allow the
2793 default handling to take place. The command events are, however, normally not
2794 skipped as usually a single command such as a button click or menu item
2795 selection must only be processed by one handler.
2797 void Skip(bool skip
= true);
2800 Stop the event from propagating to its parent window.
2801 Returns the old propagation level value which may be later passed to
2802 ResumePropagation() to allow propagating the
2805 int StopPropagation();
2808 int m_propagationLevel
2809 Indicates how many levels the event can propagate. This member is protected and
2810 should typically only be set in the constructors of the derived classes. It
2811 may be temporarily changed by StopPropagation()
2812 and ResumePropagation() and tested with
2814 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by
2815 default) meaning that the event shouldn't be propagated at all or to
2816 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
2817 propagated as much as necessary.
2818 Any positive number means that the event should be propagated but no more than
2819 the given number of times. E.g. the propagation level may be set to 1 to
2820 propagate the event to its parent only, but not to its grandparent.
2830 A size event holds information about size change events.
2832 The EVT_SIZE handler function will be called when the window has been resized.
2834 You may wish to use this for frames to resize their child windows as
2837 Note that the size passed is of
2838 the whole window: call wxWindow::GetClientSize for the area which may be
2839 used by the application.
2841 When a window is resized, usually only a small part of the window is damaged
2843 may only need to repaint that area. However, if your drawing depends on the
2845 you may need to clear the DC explicitly and repaint the whole window. In which
2847 may need to call wxWindow::Refresh to invalidate the entire window.
2852 @see wxSize, @ref overview_eventhandling
2854 class wxSizeEvent
: public wxEvent
2860 wxSizeEvent(const wxSize
& sz
, int id
= 0);
2863 Returns the entire size of the window generating the size change event.
2865 wxSize
GetSize() const;
2871 @class wxSetCursorEvent
2874 A SetCursorEvent is generated when the mouse cursor is about to be set as a
2875 result of mouse motion. This event gives the application the chance to perform
2876 specific mouse cursor processing based on the current position of the mouse
2877 within the window. Use wxSetCursorEvent::SetCursor to
2878 specify the cursor you want to be displayed.
2883 @see ::wxSetCursor, wxWindow::wxSetCursor
2885 class wxSetCursorEvent
: public wxEvent
2889 Constructor, used by the library itself internally to initialize the event
2892 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0);
2895 Returns a reference to the cursor specified by this event.
2897 const wxCursor
& GetCursor() const;
2900 Returns the X coordinate of the mouse in client coordinates.
2902 wxCoord
GetX() const;
2905 Returns the Y coordinate of the mouse in client coordinates.
2907 wxCoord
GetY() const;
2910 Returns @true if the cursor specified by this event is a valid cursor.
2912 @remarks You cannot specify wxNullCursor with this event, as it is not
2913 considered a valid cursor.
2915 bool HasCursor() const;
2918 Sets the cursor associated with this event.
2920 void SetCursor(const wxCursor
& cursor
);
2925 // ============================================================================
2926 // Global functions/macros
2927 // ============================================================================
2929 /** @ingroup group_funcmacro_misc */
2933 In a GUI application, this function posts @a event to the specified @e dest
2934 object using wxEvtHandler::AddPendingEvent().
2936 Otherwise, it dispatches @a event immediately using
2937 wxEvtHandler::ProcessEvent(). See the respective documentation for details
2942 void wxPostEvent(wxEvtHandler
* dest
, wxEvent
& event
);