1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxKeyEvent
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 overview_keycodes "keycodes table". The translated key is, in
27 general, the character the user expects to appear as the result of the key
28 combination when typing the text into a text entry zone, for example.
30 A few examples to clarify this (all assume that CAPS LOCK is unpressed
31 and the standard US keyboard): when the @c 'A' key is pressed, the key down
32 event key code is equal to @c ASCII A == 65. But the char event key code
33 is @c ASCII a == 97. On the other hand, if you press both SHIFT and
34 @c 'A' keys simultaneously , the key code in key down event will still be
35 just @c 'A' while the char event key code parameter will now be @c 'A'
38 Although in this simple case it is clear that the correct key code could be
39 found in the key down event handler by checking the value returned by
40 wxKeyEvent::ShiftDown, in general you should use
41 @c EVT_CHAR for this as for non-alphanumeric keys the translation is
42 keyboard-layout dependent and can only be done properly by the system itself.
44 Another kind of translation is done when the control key is pressed: for
45 example, for CTRL-A key press the key down event still carries the
46 same key code @c 'a' as usual but the char event will have key code of
47 1, the ASCII value of this key combination.
49 You may discover how the other keys on your system behave interactively by
50 running the text() wxWidgets sample and pressing some keys
51 in any of the text controls shown in it.
53 @b Note: If a key down (@c EVT_KEY_DOWN) event is caught and
54 the event handler does not call @c event.Skip() then the corresponding
55 char event (@c EVT_CHAR) will not happen. This is by design and
56 enables the programs that handle both types of events to be a bit
59 @b Note for Windows programmers: The key and char events in wxWidgets are
60 similar to but slightly different from Windows @c WM_KEYDOWN and
61 @c WM_CHAR events. In particular, Alt-x combination will generate a char
62 event in wxWidgets (unless it is used as an accelerator).
64 @b Tip: be sure to call @c event.Skip() for events that you don't process in
65 key event function, otherwise menu shortcuts may cease to work under Windows.
70 class wxKeyEvent
: public wxEvent
74 Constructor. Currently, the only valid event types are wxEVT_CHAR and
77 wxKeyEvent(WXTYPE keyEventType
);
80 Returns @true if the Alt key was down at the time of the key event.
81 Notice that GetModifiers() is easier to use
82 correctly than this function so you should consider using it in new code.
87 CMD is a pseudo key which is the same as Control for PC and Unix
88 platforms but the special APPLE (a.k.a as COMMAND) key under
89 Macs: it makes often sense to use it instead of, say, ControlDown() because Cmd
90 key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still
91 exists, just not used for this purpose under Mac). So for non-Mac platforms
92 this is the same as ControlDown() and under
93 Mac this is the same as MetaDown().
98 Returns @true if the control key was down at the time of the key event.
99 Notice that GetModifiers() is easier to use
100 correctly than this function so you should consider using it in new code.
102 bool ControlDown() const;
105 Returns the virtual key code. ASCII events return normal ASCII values,
106 while non-ASCII events return values such as @b WXK_LEFT for the
107 left cursor key. See Keycodes() for a full list of
108 the virtual key codes.
109 Note that in Unicode build, the returned value is meaningful only if the
110 user entered a character that can be represented in current locale's default
111 charset. You can obtain the corresponding Unicode character using
114 int GetKeyCode() const;
117 Return the bitmask of modifier keys which were pressed when this event
118 happened. See @ref overview_keymodifiers "key modifier constants" for the full
121 Notice that this function is easier to use correctly than, for example,
122 ControlDown() because when using the latter you
123 also have to remember to test that none of the other modifiers is pressed:
125 and forgetting to do it can result in serious program bugs (e.g. program not
126 working with European keyboard layout where ALTGR key which is seen by
127 the program as combination of CTRL and ALT is used). On the
128 other hand, you can simply write
132 int GetModifiers() const;
136 Obtains the position (in client coordinates) at which the key was pressed.
138 wxPoint
GetPosition() const;
139 const void GetPosition(long* x
, long* y
) const;
143 Returns the raw key code for this event. This is a platform-dependent scan code
144 which should only be used in advanced applications.
145 @b NB: Currently the raw key codes are not supported by all ports, use
146 @c #ifdef wxHAS_RAW_KEY_CODES to determine if this feature is available.
148 wxUint32
GetRawKeyCode() const;
151 Returns the low level key flags for this event. The flags are
152 platform-dependent and should only be used in advanced applications.
153 @b NB: Currently the raw key flags are not supported by all ports, use
154 @c #ifdef wxHAS_RAW_KEY_CODES to determine if this feature is available.
156 wxUint32
GetRawKeyFlags() const;
159 Returns the Unicode character corresponding to this key event.
160 This function is only available in Unicode build, i.e. when
161 @c wxUSE_UNICODE is 1.
163 wxChar
GetUnicodeKey() const;
166 Returns the X position (in client coordinates) of the event.
171 Returns the Y (in client coordinates) position of the event.
176 Returns @true if either CTRL or ALT keys was down
177 at the time of the key event. Note that this function does not take into
178 account neither SHIFT nor META key states (the reason for ignoring
179 the latter is that it is common for NUMLOCK key to be configured as
180 META under X but the key presses even while NUMLOCK is on should
181 be still processed normally).
183 bool HasModifiers() const;
186 Returns @true if the Meta key was down at the time of the key event.
187 Notice that GetModifiers() is easier to use
188 correctly than this function so you should consider using it in new code.
190 bool MetaDown() const;
193 Returns @true if the shift key was down at the time of the key event.
194 Notice that GetModifiers() is easier to use
195 correctly than this function so you should consider using it in new code.
197 bool ShiftDown() const;
201 @b Deprecated: Please use GetModifiers()
203 @true if the Alt key is pressed down.
209 @b Deprecated: Please use GetModifiers()
211 @true if control is pressed down.
217 @b Deprecated: Please use GetKeyCode()
219 Virtual keycode. See Keycodes() for a list of identifiers.
225 @b Deprecated: Please use GetModifiers()
227 @true if the Meta key is pressed down.
233 @b Deprecated: Please use GetModifiers()
235 @true if shift is pressed down.
241 @b Deprecated: Please use GetX() instead!
242 X position of the event.
248 @b Deprecated: Please use GetY() instead!
249 Y position of the event.
256 @class wxJoystickEvent
259 This event class contains information about mouse events, particularly
260 events received by windows.
267 class wxJoystickEvent
: public wxEvent
273 wxJoystickEvent(WXTYPE eventType
= 0, int state
= 0,
274 int joystick
= wxJOYSTICK1
,
278 Returns @true if the event was a down event from the specified button (or any
282 Can be wxJOY_BUTTONn where n is 1, 2, 3 or 4; or wxJOY_BUTTON_ANY to
283 indicate any button down event.
285 bool ButtonDown(int button
= wxJOY_BUTTON_ANY
) const;
288 Returns @true if the specified button (or any button) was in a down state.
291 Can be wxJOY_BUTTONn where n is 1, 2, 3 or 4; or wxJOY_BUTTON_ANY to
292 indicate any button down event.
294 bool ButtonIsDown(int button
= wxJOY_BUTTON_ANY
) const;
297 Returns @true if the event was an up event from the specified button (or any
301 Can be wxJOY_BUTTONn where n is 1, 2, 3 or 4; or wxJOY_BUTTON_ANY to
302 indicate any button down event.
304 bool ButtonUp(int button
= wxJOY_BUTTON_ANY
) const;
307 Returns the identifier of the button changing state. This is a wxJOY_BUTTONn
309 n is one of 1, 2, 3, 4.
311 int GetButtonChange() const;
314 Returns the down state of the buttons. This is a bitlist of wxJOY_BUTTONn
316 n is one of 1, 2, 3, 4.
318 int GetButtonState() const;
321 Returns the identifier of the joystick generating the event - one of
322 wxJOYSTICK1 and wxJOYSTICK2.
324 int GetJoystick() const;
327 Returns the x, y position of the joystick event.
329 wxPoint
GetPosition() const;
332 Returns the z position of the joystick event.
334 int GetZPosition() const;
337 Returns @true if this was a button up or down event (@e not 'is any button
340 bool IsButton() const;
343 Returns @true if this was an x, y move event.
348 Returns @true if this was a z move event.
350 bool IsZMove() const;
356 @class wxScrollWinEvent
359 A scroll event holds information about events sent from scrolling windows.
364 @see wxScrollEvent, @ref overview_eventhandlingoverview
366 class wxScrollWinEvent
: public wxEvent
372 wxScrollWinEvent(WXTYPE commandType
= 0, int pos
= 0,
373 int orientation
= 0);
376 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
379 int GetOrientation() const;
382 Returns the position of the scrollbar for the thumb track and release events.
383 Note that this field can't be used for the other events, you need to query
384 the window itself for the current position in that case.
386 int GetPosition() const;
392 @class wxSysColourChangedEvent
395 This class is used for system colour change events, which are generated
396 when the user changes the colour settings using the control panel.
397 This is only appropriate under Windows.
402 @see @ref overview_eventhandlingoverview
404 class wxSysColourChangedEvent
: public wxEvent
410 wxSysColourChangedEvent();
416 @class wxWindowCreateEvent
419 This event is sent just after the actual window associated with a wxWindow
421 has been created. Since it is derived from wxCommandEvent, the event propagates
423 the window hierarchy.
428 @see @ref overview_eventhandlingoverview, wxWindowDestroyEvent
430 class wxWindowCreateEvent
: public wxCommandEvent
436 wxWindowCreateEvent(wxWindow
* win
= NULL
);
445 A paint event is sent when a window's contents needs to be repainted.
447 Please notice that in general it is impossible to change the drawing of a
448 standard control (such as wxButton) and so you shouldn't
449 attempt to handle paint events for them as even if it might work on some
450 platforms, this is inherently not portable and won't work everywhere.
455 @see @ref overview_eventhandlingoverview
457 class wxPaintEvent
: public wxEvent
463 wxPaintEvent(int id
= 0);
469 @class wxMaximizeEvent
472 An event being sent when a top level window is maximized. Notice that it is
473 not sent when the window is restored to its original size after it had been
474 maximized, only a normal wxSizeEvent is generated in
480 @see @ref overview_eventhandlingoverview, wxTopLevelWindow::Maximize,
481 wxTopLevelWindow::IsMaximized
483 class wxMaximizeEvent
: public wxEvent
487 Constructor. Only used by wxWidgets internally.
489 wxMaximizeEvent(int id
= 0);
495 @class wxUpdateUIEvent
498 This class is used for pseudo-events which are called by wxWidgets
499 to give an application the chance to update various user interface elements.
504 @see @ref overview_eventhandlingoverview
506 class wxUpdateUIEvent
: public wxCommandEvent
512 wxUpdateUIEvent(wxWindowID commandId
= 0);
515 Returns @true if it is appropriate to update (send UI update events to)
517 This function looks at the mode used (see wxUpdateUIEvent::SetMode),
518 the wxWS_EX_PROCESS_UI_UPDATES flag in @e window,
519 the time update events were last sent in idle time, and
520 the update interval, to determine whether events should be sent to
521 this window now. By default this will always return @true because
522 the update mode is initially wxUPDATE_UI_PROCESS_ALL and
523 the interval is set to 0; so update events will be sent as
524 often as possible. You can reduce the frequency that events
525 are sent by changing the mode and/or setting an update interval.
527 @see ResetUpdateTime(), SetUpdateInterval(),
530 static bool CanUpdate(wxWindow
* window
);
533 Check or uncheck the UI element.
535 void Check(bool check
);
538 Enable or disable the UI element.
540 void Enable(bool enable
);
543 Returns @true if the UI element should be checked.
545 bool GetChecked() const;
548 Returns @true if the UI element should be enabled.
550 bool GetEnabled() const;
553 Static function returning a value specifying how wxWidgets
554 will send update events: to all windows, or only to those which specify that
556 will process the events.
559 static wxUpdateUIMode
GetMode();
562 Returns @true if the application has called Check(). For wxWidgets internal use
565 bool GetSetChecked() const;
568 Returns @true if the application has called Enable(). For wxWidgets internal use
571 bool GetSetEnabled() const;
574 Returns @true if the application has called Show(). For wxWidgets internal use
577 bool GetSetShown() const;
580 Returns @true if the application has called SetText(). For wxWidgets internal
583 bool GetSetText() const;
586 Returns @true if the UI element should be shown.
588 bool GetShown() const;
591 Returns the text that should be set for the UI element.
593 wxString
GetText() const;
596 Returns the current interval between updates in milliseconds.
597 -1 disables updates, 0 updates as frequently as possible.
598 See SetUpdateInterval().
600 static long GetUpdateInterval();
603 Used internally to reset the last-updated time to the
604 current time. It is assumed that update events are
605 normally sent in idle time, so this is called at the end of
608 @see CanUpdate(), SetUpdateInterval(),
611 static void ResetUpdateTime();
614 Specify how wxWidgets will send update events: to
615 all windows, or only to those which specify that they
616 will process the events.
617 @a mode may be one of the following values.
618 The default is wxUPDATE_UI_PROCESS_ALL.
620 static void SetMode(wxUpdateUIMode mode
);
623 Sets the text for this UI element.
625 void SetText(const wxString
& text
);
628 Sets the interval between updates in milliseconds.
629 Set to -1 to disable updates, or to 0 to update as frequently as possible.
631 Use this to reduce the overhead of UI update events if your application
632 has a lot of windows. If you set the value to -1 or greater than 0,
633 you may also need to call wxWindow::UpdateWindowUI
634 at appropriate points in your application, such as when a dialog
635 is about to be shown.
637 static void SetUpdateInterval(long updateInterval
);
640 Show or hide the UI element.
642 void Show(bool show
);
648 @class wxClipboardTextEvent
651 This class represents the events generated by a control (typically a
652 wxTextCtrl but other windows can generate these events as
653 well) when its content gets copied or cut to, or pasted from the clipboard.
654 There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY,
655 wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE.
657 If any of these events is processed (without being skipped) by an event
658 handler, the corresponding operation doesn't take place which allows to
659 prevent the text from being copied from or pasted to a control. It is also
660 possible to examine the clipboard contents in the PASTE event handler and
661 transform it in some way before inserting in a control -- for example,
662 changing its case or removing invalid characters.
664 Finally notice that a CUT event is always preceded by the COPY event which
665 makes it possible to only process the latter if it doesn't matter if the
666 text was copied or cut.
669 @event{EVT_TEXT_COPY(id, func)}:
670 Some or all of the controls content was copied to the clipboard.
671 @event{EVT_TEXT_CUT(id, func)}:
672 Some or all of the controls content was cut (i.e. copied and
674 @event{EVT_TEXT_PASTE(id, func)}:
675 Clipboard content was pasted into the control.
679 These events are currently only generated by wxTextCtrl under GTK+. They
680 are generated by all controls under Windows.
687 class wxClipboardTextEvent
: public wxCommandEvent
693 wxClipboardTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
702 This event class contains information about the events generated by the mouse:
703 they include mouse buttons press and release events and mouse move events.
705 All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
706 left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
707 @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
708 buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
709 can also be generated. Note that not all mice have even a middle button so a
710 portable application should avoid relying on the events from it (but the right
711 button click can be emulated using the left mouse button with the control key
712 under Mac platforms with a single button mouse).
714 For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
715 purposes, the mouse is considered to be inside the window if it is in the
716 window client area and not inside one of its children. In other words, the
717 parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
718 mouse leaves the window entirely but also when it enters one of its children.
720 @b NB: Note that under Windows CE mouse enter and leave events are not natively
722 by the system but are generated by wxWidgets itself. This has several
723 drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
724 left the window and the state variables for it may have changed during this
727 @b NB: Note the difference between methods like
728 wxMouseEvent::LeftDown and
729 wxMouseEvent::LeftIsDown: the former returns @true
730 when the event corresponds to the left mouse button click while the latter
731 returns @true if the left mouse button is currently being pressed. For
732 example, when the user is dragging the mouse you can use
733 wxMouseEvent::LeftIsDown to test
734 whether the left mouse button is (still) depressed. Also, by convention, if
735 wxMouseEvent::LeftDown returns @true,
736 wxMouseEvent::LeftIsDown will also return @true in
737 wxWidgets whatever the underlying GUI behaviour is (which is
738 platform-dependent). The same applies, of course, to other mouse buttons as
744 @see wxKeyEvent::CmdDown
746 class wxMouseEvent
: public wxEvent
750 Constructor. Valid event types are:
752 @b wxEVT_ENTER_WINDOW
753 @b wxEVT_LEAVE_WINDOW
759 @b wxEVT_MIDDLE_DCLICK
762 @b wxEVT_RIGHT_DCLICK
763 @b wxEVT_MOUSE_AUX1_DOWN
764 @b wxEVT_MOUSE_AUX1_UP
765 @b wxEVT_MOUSE_AUX1_DCLICK
766 @b wxEVT_MOUSE_AUX2_DOWN
767 @b wxEVT_MOUSE_AUX2_UP
768 @b wxEVT_MOUSE_AUX2_DCLICK
772 wxMouseEvent(WXTYPE mouseEventType
= 0);
775 Returns @true if the Alt key was down at the time of the event.
780 Returns @true if the event was a first extra button double click.
782 bool Aux1DClick() const;
785 Returns @true if the first extra button mouse button changed to down.
787 bool Aux1Down() const;
790 Returns @true if the first extra button mouse button is currently down,
792 of the current event type.
794 bool Aux1IsDown() const;
797 Returns @true if the first extra button mouse button changed to up.
802 Returns @true if the event was a second extra button double click.
804 bool Aux2DClick() const;
807 Returns @true if the second extra button mouse button changed to down.
809 bool Aux2Down() const;
812 Returns @true if the second extra button mouse button is currently down,
814 of the current event type.
816 bool Aux2IsDown() const;
819 Returns @true if the second extra button mouse button changed to up.
824 Returns @true if the identified mouse button is changing state. Valid
825 values of @a button are:
829 check if left button was pressed
831 @c wxMOUSE_BTN_MIDDLE
833 check if middle button was pressed
837 check if right button was pressed
841 check if the first extra button was pressed
845 check if the second extra button was pressed
849 check if any button was pressed
851 bool Button(int button
);
854 If the argument is omitted, this returns @true if the event was a mouse
855 double click event. Otherwise the argument specifies which double click event
856 was generated (see Button() for the possible
859 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
);
862 If the argument is omitted, this returns @true if the event was a mouse
863 button down event. Otherwise the argument specifies which button-down event
864 was generated (see Button() for the possible
867 bool ButtonDown(int but
= -1);
870 If the argument is omitted, this returns @true if the event was a mouse
871 button up event. Otherwise the argument specifies which button-up event
872 was generated (see Button() for the possible
875 bool ButtonUp(int but
= -1);
878 Same as MetaDown() under Mac, same as
879 ControlDown() elsewhere.
881 @see wxKeyEvent::CmdDown
883 bool CmdDown() const;
886 Returns @true if the control key was down at the time of the event.
891 Returns @true if this was a dragging event (motion while a button is depressed).
898 Returns @true if the mouse was entering the window.
904 Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
905 if no button is involved (for mouse move, enter or leave event, for example).
906 Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
907 double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
908 for the same events for the middle and the right buttons respectively.
910 int GetButton() const;
913 Returns the number of mouse clicks for this event: 1 for a simple click, 2
914 for a double-click, 3 for a triple-click and so on.
915 Currently this function is implemented only in wxMac and returns -1 for the
916 other platforms (you can still distinguish simple clicks from double-clicks as
917 they generate different kinds of events however).
921 int GetClickCount() const;
924 Returns the configured number of lines (or whatever) to be scrolled per
925 wheel action. Defaults to three.
927 int GetLinesPerAction() const;
930 Returns the logical mouse position in pixels (i.e. translated according to the
931 translation set for the DC, which usually indicates that the window has been
934 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
938 Sets *x and *y to the position at which the event occurred.
939 Returns the physical mouse position in pixels.
940 Note that if the mouse event has been artificially generated from a special
941 keyboard combination (e.g. under Windows when the "menu'' key is pressed), the
942 returned position is @c wxDefaultPosition.
944 wxPoint
GetPosition() const;
945 const void GetPosition(wxCoord
* x
, wxCoord
* y
) const;
946 const void GetPosition(long* x
, long* y
) const;
950 Get wheel delta, normally 120. This is the threshold for action to be
951 taken, and one such action (for example, scrolling one increment)
952 should occur for each delta.
954 int GetWheelDelta() const;
957 Get wheel rotation, positive or negative indicates direction of
958 rotation. Current devices all send an event when rotation is at least
959 +/-WheelDelta, but finer resolution devices can be created in the future.
960 Because of this you shouldn't assume that one event is equal to 1 line, but you
961 should be able to either do partial line scrolling or wait until several
962 events accumulate before scrolling.
964 int GetWheelRotation() const;
967 Returns X coordinate of the physical mouse event position.
972 Returns Y coordinate of the physical mouse event position.
977 Returns @true if the event was a mouse button event (not necessarily a button
979 that may be tested using @e ButtonDown).
981 bool IsButton() const;
984 Returns @true if the system has been setup to do page scrolling with
985 the mouse wheel instead of line scrolling.
987 bool IsPageScroll() const;
990 Returns @true if the mouse was leaving the window.
993 bool Leaving() const;
996 Returns @true if the event was a left double click.
998 bool LeftDClick() const;
1001 Returns @true if the left mouse button changed to down.
1003 bool LeftDown() const;
1006 Returns @true if the left mouse button is currently down, independent
1007 of the current event type.
1008 Please notice that it is not the same as
1009 LeftDown() which returns @true if the event was
1010 generated by the left mouse button being pressed. Rather, it simply describes
1011 the state of the left mouse button at the time when the event was generated
1012 (so while it will be @true for a left click event, it can also be @true for
1013 a right click if it happened while the left mouse button was pressed).
1014 This event is usually used in the mouse event handlers which process "move
1015 mouse" messages to determine whether the user is (still) dragging the mouse.
1017 bool LeftIsDown() const;
1020 Returns @true if the left mouse button changed to up.
1022 bool LeftUp() const;
1025 Returns @true if the Meta key was down at the time of the event.
1027 bool MetaDown() const;
1030 Returns @true if the event was a middle double click.
1032 bool MiddleDClick() const;
1035 Returns @true if the middle mouse button changed to down.
1037 bool MiddleDown() const;
1040 Returns @true if the middle mouse button is currently down, independent
1041 of the current event type.
1043 bool MiddleIsDown() const;
1046 Returns @true if the middle mouse button changed to up.
1048 bool MiddleUp() const;
1051 Returns @true if this was a motion event and no mouse buttons were pressed.
1052 If any mouse button is held pressed, then this method returns @false and
1053 Dragging() returns @true.
1055 bool Moving() const;
1058 Returns @true if the event was a right double click.
1060 bool RightDClick() const;
1063 Returns @true if the right mouse button changed to down.
1065 bool RightDown() const;
1068 Returns @true if the right mouse button is currently down, independent
1069 of the current event type.
1071 bool RightIsDown() const;
1074 Returns @true if the right mouse button changed to up.
1076 bool RightUp() const;
1079 Returns @true if the shift key was down at the time of the event.
1081 bool ShiftDown() const;
1085 @true if the Alt key is pressed down.
1091 @true if control key is pressed down.
1097 @true if the left mouse button is currently pressed down.
1102 int m_linesPerAction
1103 The configured number of lines (or whatever) to be scrolled per wheel
1110 @true if the Meta key is pressed down.
1116 @true if the middle mouse button is currently pressed down.
1122 @true if the right mouse button is currently pressed down.
1128 @true if shift is pressed down.
1134 The wheel delta, normally 120.
1140 The distance the mouse wheel is rotated.
1146 X-coordinate of the event.
1152 Y-coordinate of the event.
1159 @class wxDropFilesEvent
1162 This class is used for drop files events, that is, when files have been dropped
1163 onto the window. This functionality is currently only available under Windows.
1164 The window must have previously been enabled for dropping by calling
1165 wxWindow::DragAcceptFiles.
1167 Important note: this is a separate implementation to the more general
1168 drag and drop implementation documented here(). It uses the
1169 older, Windows message-based approach of dropping files.
1174 @see @ref overview_eventhandlingoverview
1176 class wxDropFilesEvent
: public wxEvent
1182 wxDropFilesEvent(WXTYPE id
= 0, int noFiles
= 0,
1183 wxString
* files
= NULL
);
1186 Returns an array of filenames.
1188 wxString
* GetFiles() const;
1191 Returns the number of files dropped.
1193 int GetNumberOfFiles() const;
1196 Returns the position at which the files were dropped.
1197 Returns an array of filenames.
1199 wxPoint
GetPosition() const;
1203 An array of filenames.
1209 The number of files dropped.
1215 The point at which the drop took place.
1222 @class wxCommandEvent
1225 This event class contains information about command events, which originate
1227 simple controls. More complex controls, such as wxTreeCtrl, have separate
1228 command event classes.
1233 class wxCommandEvent
: public wxEvent
1239 wxCommandEvent(WXTYPE commandEventType
= 0, int id
= 0);
1242 Deprecated, use IsChecked() instead.
1244 bool Checked() const;
1247 Returns client data pointer for a listbox or choice selection event
1248 (not valid for a deselection).
1250 void* GetClientData();
1253 Returns client object pointer for a listbox or choice selection event
1254 (not valid for a deselection).
1256 wxClientData
* GetClientObject();
1259 Returns extra information dependant on the event objects type.
1260 If the event comes from a listbox selection, it is a boolean
1261 determining whether the event was a selection (@true) or a
1262 deselection (@false). A listbox deselection only occurs for
1263 multiple-selection boxes, and in this case the index and string values
1264 are indeterminate and the listbox must be examined by the application.
1266 long GetExtraLong();
1269 Returns the integer identifier corresponding to a listbox, choice or
1270 radiobox selection (only if the event was a selection, not a
1271 deselection), or a boolean value representing the value of a checkbox.
1276 Returns item index for a listbox or choice selection event (not valid for
1282 Returns item string for a listbox or choice selection event (not valid for
1285 wxString
GetString();
1288 This method can be used with checkbox and menu events: for the checkboxes, the
1289 method returns @true for a selection event and @false for a
1290 deselection one. For the menu events, this method indicates if the menu item
1291 just has become checked or unchecked (and thus only makes sense for checkable
1293 Notice that this method can not be used with
1294 wxCheckListBox currently.
1296 bool IsChecked() const;
1299 For a listbox or similar event, returns @true if it is a selection, @false if it
1305 Sets the client data for this event.
1307 void SetClientData(void* clientData
);
1310 Sets the client object for this event. The client object is not owned by the
1312 object and the event object will not delete the client object in its destructor.
1313 The client object must be owned and deleted by another object (e.g. a control)
1314 that has longer life time than the event object.
1316 void SetClientObject(wxClientData
* clientObject
);
1319 Sets the @b m_extraLong member.
1321 void SetExtraLong(long extraLong
);
1324 Sets the @b m_commandInt member.
1326 void SetInt(int intCommand
);
1329 Sets the @b m_commandString member.
1331 void SetString(const wxString
& string
);
1337 @class wxActivateEvent
1340 An activate event is sent when a window or application is being activated
1346 @see @ref overview_eventhandlingoverview, wxApp::IsActive
1348 class wxActivateEvent
: public wxEvent
1354 wxActivateEvent(WXTYPE eventType
= 0, bool active
= true,
1358 Returns @true if the application or window is being activated, @false otherwise.
1360 bool GetActive() const;
1366 @class wxContextMenuEvent
1369 This class is used for context menu events, sent to give
1370 the application a chance to show a context (popup) menu.
1372 Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
1373 means that the event originated
1374 from a keyboard context button event, and you should compute a suitable
1376 for example by calling wxGetMousePosition().
1378 When a keyboard context menu button is pressed on Windows, a right-click event
1379 with default position is sent first,
1380 and if this event is not processed, the context menu event is sent. So if you
1381 process mouse events and you find your context menu event handler
1382 is not being called, you could call wxEvent::Skip for mouse right-down events.
1387 @see @ref overview_wxcommandevent "Command events", @ref
1388 overview_eventhandlingoverview
1390 class wxContextMenuEvent
: public wxCommandEvent
1396 wxContextMenuEvent(WXTYPE id
= 0, int id
= 0,
1397 const wxPoint
& pos
= wxDefaultPosition
);
1400 Returns the position in screen coordinates at which the menu should be shown.
1401 Use wxWindow::ScreenToClient to
1402 convert to client coordinates. You can also omit a position from
1403 wxWindow::PopupMenu in order to use
1404 the current mouse pointer position.
1405 If the event originated from a keyboard event, the value returned from this
1406 function will be wxDefaultPosition.
1408 wxPoint
GetPosition() const;
1411 Sets the position at which the menu should be shown.
1413 void SetPosition(const wxPoint
& point
);
1422 An erase event is sent when a window's background needs to be repainted.
1424 On some platforms, such as GTK+, this event is simulated (simply generated just
1426 paint event) and may cause flicker. It is therefore recommended that
1427 you set the text background colour explicitly in order to prevent flicker.
1428 The default background colour under GTK+ is grey.
1430 To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
1433 You must call wxEraseEvent::GetDC and use the returned device context if it is
1435 If it is @NULL, create your own temporary wxClientDC object.
1440 @see @ref overview_eventhandlingoverview
1442 class wxEraseEvent
: public wxEvent
1448 wxEraseEvent(int id
= 0, wxDC
* dc
= NULL
);
1451 Returns the device context associated with the erase event to draw on.
1453 wxDC
* GetDC() const;
1462 A focus event is sent when a window's focus changes. The window losing focus
1463 receives a "kill focus'' event while the window gaining it gets a "set
1466 Notice that the set focus event happens both when the user gives focus to the
1467 window (whether using the mouse or keyboard) and when it is done from the
1468 program itself using wxWindow::SetFocus.
1473 @see @ref overview_eventhandlingoverview
1475 class wxFocusEvent
: public wxEvent
1481 wxFocusEvent(WXTYPE eventType
= 0, int id
= 0);
1484 Returns the window associated with this event, that is the window which had the
1485 focus before for the @c wxEVT_SET_FOCUS event and the window which is
1486 going to receive focus for the @c wxEVT_KILL_FOCUS one.
1487 Warning: the window pointer may be @NULL!
1494 @class wxChildFocusEvent
1497 A child focus event is sent to a (parent-)window when one of its child windows
1499 so that the window could restore the focus back to its corresponding child
1500 if it loses it now and regains later.
1502 Notice that child window is the direct child of the window receiving event.
1503 Use wxWindow::FindFocus to retreive the window which is actually getting focus.
1508 @see @ref overview_eventhandlingoverview
1510 class wxChildFocusEvent
: public wxCommandEvent
1517 The direct child which is (or which contains the window which is) receiving
1520 wxChildFocusEvent(wxWindow
* win
= NULL
);
1523 Returns the direct child which receives the focus, or a (grand-)parent of the
1524 control receiving the focus.
1525 To get the actually focused control use wxWindow::FindFocus.
1532 @class wxMouseCaptureLostEvent
1535 An mouse capture lost event is sent to a window that obtained mouse capture,
1536 which was subsequently loss due to "external" event, for example when a dialog
1537 box is shown or if another application captures the mouse.
1539 If this happens, this event is sent to all windows that are on capture stack
1540 (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
1541 not sent if the capture changes because of a call to CaptureMouse or
1544 This event is currently emitted under Windows only.
1549 @see wxMouseCaptureChangedEvent, @ref overview_eventhandlingoverview,
1550 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
1552 class wxMouseCaptureLostEvent
: public wxEvent
1558 wxMouseCaptureLostEvent(wxWindowID windowId
= 0);
1564 @class wxNotifyEvent
1567 This class is not used by the event handlers by itself, but is a base class
1568 for other event classes (such as wxNotebookEvent).
1570 It (or an object of a derived class) is sent when the controls state is being
1571 changed and allows the program to wxNotifyEvent::Veto this
1572 change if it wants to prevent it from happening.
1577 @see wxNotebookEvent
1579 class wxNotifyEvent
: public wxCommandEvent
1583 Constructor (used internally by wxWidgets only).
1585 wxNotifyEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
1588 This is the opposite of Veto(): it explicitly
1589 allows the event to be processed. For most events it is not necessary to call
1590 this method as the events are allowed anyhow but some are forbidden by default
1591 (this will be mentioned in the corresponding event description).
1596 Returns @true if the change is allowed (Veto()
1597 hasn't been called) or @false otherwise (if it was).
1599 bool IsAllowed() const;
1602 Prevents the change announced by this event from happening.
1603 It is in general a good idea to notify the user about the reasons for vetoing
1604 the change because otherwise the applications behaviour (which just refuses to
1605 do what the user wants) might be quite surprising.
1616 A help event is sent when the user has requested context-sensitive help.
1617 This can either be caused by the application requesting
1618 context-sensitive help mode via wxContextHelp, or
1619 (on MS Windows) by the system generating a WM_HELP message when the user
1620 pressed F1 or clicked
1621 on the query button in a dialog caption.
1623 A help event is sent to the window that the user clicked on, and is propagated
1625 window hierarchy until the event is processed or there are no more event
1627 The application should call wxEvent::GetId to check the identity of the
1629 and then either show some suitable help or call wxEvent::Skip if the identifier
1631 Calling Skip is important because it allows wxWidgets to generate further
1632 events for ancestors
1633 of the clicked-on window. Otherwise it would be impossible to show help for
1635 since processing would stop after the first window found.
1640 @see wxContextHelp, wxDialog, @ref overview_eventhandlingoverview
1642 class wxHelpEvent
: public wxCommandEvent
1648 wxHelpEvent(WXTYPE eventType
= 0, wxWindowID id
= 0,
1649 const wxPoint
& point
);
1652 Returns the origin of the help event which is one of the following values:
1656 Unrecognized event source.
1660 Event generated by @c F1 key press.
1662 @b Origin_HelpButton
1665 wxContextHelp or using the "?" title bur button under
1668 The application may handle events generated using the keyboard or mouse
1669 differently, e.g. by using wxGetMousePosition()
1670 for the mouse events.
1674 wxHelpEvent::Origin
GetOrigin() const;
1677 Returns the left-click position of the mouse, in screen coordinates. This allows
1678 the application to position the help appropriately.
1680 const wxPoint
GetPosition() const;
1683 Set the help event origin, only used internally by wxWidgets normally.
1687 void SetOrigin(wxHelpEvent::Origin origin
);
1690 Sets the left-click position of the mouse, in screen coordinates.
1692 void SetPosition(const wxPoint
& pt
);
1698 @class wxScrollEvent
1701 A scroll event holds information about events sent from stand-alone
1702 scrollbars() and sliders(). Note that
1703 starting from wxWidgets 2.1, scrolled windows send the
1704 wxScrollWinEvent which does not derive from
1705 wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
1706 events and use the event table macros mentioned below only for the
1707 scrollbar-like controls.
1712 @see wxScrollBar, wxSlider, wxSpinButton, , wxScrollWinEvent, @ref
1713 overview_eventhandlingoverview
1715 class wxScrollEvent
: public wxCommandEvent
1721 wxScrollEvent(WXTYPE commandType
= 0, int id
= 0, int pos
= 0,
1722 int orientation
= 0);
1725 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
1728 int GetOrientation() const;
1731 Returns the position of the scrollbar.
1733 int GetPosition() const;
1742 This class is used for idle events, which are generated when the system becomes
1743 idle. Note that, unless you do something specifically, the idle events are not
1744 sent if the system remains idle once it has become it, e.g. only a single idle
1745 event will be generated until something else resulting in more normal events
1746 happens and only then is the next idle event sent again. If you need to ensure
1747 a continuous stream of idle events, you can either use
1748 wxIdleEvent::RequestMore method in your handler or call
1749 wxWakeUpIdle() periodically (for example from timer
1750 event), but note that both of these approaches (and especially the first one)
1751 increase the system load and so should be avoided if possible.
1753 By default, idle events are sent to all windows (and also
1754 wxApp, as usual). If this is causing a significant
1755 overhead in your application, you can call wxIdleEvent::SetMode with
1756 the value wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra
1757 window style for every window which should receive idle events.
1762 @see @ref overview_eventhandlingoverview, wxUpdateUIEvent,
1763 wxWindow::OnInternalIdle
1765 class wxIdleEvent
: public wxEvent
1774 Returns @true if it is appropriate to send idle events to
1776 This function looks at the mode used (see wxIdleEvent::SetMode),
1777 and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle
1778 events should be sent to
1779 this window now. By default this will always return @true because
1780 the update mode is initially wxIDLE_PROCESS_ALL. You can change the mode
1781 to only send idle events to windows with the wxWS_EX_PROCESS_IDLE extra window
1786 static bool CanSend(wxWindow
* window
);
1789 Static function returning a value specifying how wxWidgets
1790 will send idle events: to all windows, or only to those which specify that they
1791 will process the events.
1794 static wxIdleMode
GetMode();
1797 Returns @true if the OnIdle function processing this event requested more
1802 bool MoreRequested() const;
1805 Tells wxWidgets that more processing is required. This function can be called
1807 handler for a window or window event handler to indicate that wxApp::OnIdle
1809 forward the OnIdle event once more to the application windows. If no window
1811 during OnIdle, then the application will remain in a passive event loop (not
1812 calling OnIdle) until a
1813 new event is posted to the application by the windowing system.
1815 @see MoreRequested()
1817 void RequestMore(bool needMore
= true);
1820 Static function for specifying how wxWidgets will send idle events: to
1821 all windows, or only to those which specify that they
1822 will process the events.
1823 @a mode can be one of the following values.
1824 The default is wxIDLE_PROCESS_ALL.
1826 static void SetMode(wxIdleMode mode
);
1832 @class wxInitDialogEvent
1835 A wxInitDialogEvent is sent as a dialog or panel is being initialised.
1836 Handlers for this event can transfer data to the window.
1837 The default handler calls wxWindow::TransferDataToWindow.
1842 @see @ref overview_eventhandlingoverview
1844 class wxInitDialogEvent
: public wxEvent
1850 wxInitDialogEvent(int id
= 0);
1856 @class wxWindowDestroyEvent
1859 This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a
1860 window is destroyed.
1862 When a class derived from wxWindow is destroyed its destructor will have
1863 already run by the time this event is sent. Therefore this event will not
1864 usually be received at all.
1866 To receive this event wxEvtHandler::Connect
1867 must be used (using an event table macro will not work). Since it is
1868 received after the destructor has run, an object should not handle its
1869 own wxWindowDestroyEvent, but it can be used to get notification of the
1870 destruction of another window.
1875 @see @ref overview_eventhandlingoverview, wxWindowCreateEvent
1877 class wxWindowDestroyEvent
: public wxCommandEvent
1883 wxWindowDestroyEvent(wxWindow
* win
= NULL
);
1889 @class wxNavigationKeyEvent
1892 This event class contains information about navigation events,
1893 generated by navigation keys such as tab and page down.
1895 This event is mainly used by wxWidgets implementations. A
1896 wxNavigationKeyEvent handler is automatically provided by wxWidgets
1897 when you make a class into a control container with the macro
1898 WX_DECLARE_CONTROL_CONTAINER.
1903 @see wxWindow::Navigate, wxWindow::NavigateIn
1905 class wxNavigationKeyEvent
1912 wxNavigationKeyEvent();
1913 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
);
1917 Returns the child that has the focus, or @NULL.
1919 wxWindow
* GetCurrentFocus() const;
1922 Returns @true if the navigation was in the forward direction.
1924 bool GetDirection() const;
1927 Returns @true if the navigation event was from a tab key. This is required
1928 for proper navigation over radio buttons.
1930 bool IsFromTab() const;
1933 Returns @true if the navigation event represents a window change (for
1934 example, from Ctrl-Page Down
1937 bool IsWindowChange() const;
1940 Sets the current focus window member.
1942 void SetCurrentFocus(wxWindow
* currentFocus
);
1945 Sets the direction to forward if @a direction is @true, or backward if @c
1948 void SetDirection(bool direction
);
1953 void SetFlags(long flags
);
1956 Marks the navigation event as from a tab key.
1958 void SetFromTab(bool fromTab
);
1961 Marks the event as a window change event.
1963 void SetWindowChange(bool windowChange
);
1969 @class wxMouseCaptureChangedEvent
1972 An mouse capture changed event is sent to a window that loses its
1973 mouse capture. This is called even if wxWindow::ReleaseCapture
1974 was called by the application code. Handling this event allows
1975 an application to cater for unexpected capture releases which
1976 might otherwise confuse mouse handling code.
1978 This event is implemented under Windows only.
1983 @see wxMouseCaptureLostEvent, @ref overview_eventhandlingoverview,
1984 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
1986 class wxMouseCaptureChangedEvent
: public wxEvent
1992 wxMouseCaptureChangedEvent(wxWindowID windowId
= 0,
1993 wxWindow
* gainedCapture
= NULL
);
1996 Returns the window that gained the capture, or @NULL if it was a non-wxWidgets
1999 wxWindow
* GetCapturedWindow() const;
2008 This event class contains information about window and session close events.
2010 The handler function for EVT_CLOSE is called when the user has tried to close a
2012 or dialog box using the window manager (X) or system menu (Windows). It can
2013 also be invoked by the application itself programmatically, for example by
2014 calling the wxWindow::Close function.
2016 You should check whether the application is forcing the deletion of the window
2017 using wxCloseEvent::CanVeto. If this is @false,
2018 you @e must destroy the window using wxWindow::Destroy.
2019 If the return value is @true, it is up to you whether you respond by destroying
2022 If you don't destroy the window, you should call wxCloseEvent::Veto to
2023 let the calling code know that you did not destroy the window. This allows the
2024 wxWindow::Close function
2025 to return @true or @false depending on whether the close instruction was
2031 @see wxWindow::Close, @ref overview_windowdeletionoverview "Window deletion
2034 class wxCloseEvent
: public wxEvent
2040 wxCloseEvent(WXTYPE commandEventType
= 0, int id
= 0);
2043 Returns @true if you can veto a system shutdown or a window close event.
2044 Vetoing a window close event is not possible if the calling code wishes to
2045 force the application to exit, and so this function must be called to check
2051 Returns @true if the user is just logging off or @false if the system is
2052 shutting down. This method can only be called for end session and query end
2053 session events, it doesn't make sense for close window event.
2055 bool GetLoggingOff() const;
2058 Sets the 'can veto' flag.
2060 void SetCanVeto(bool canVeto
);
2063 Sets the 'force' flag.
2065 void SetForce(bool force
) const;
2068 Sets the 'logging off' flag.
2070 void SetLoggingOff(bool loggingOff
) const;
2073 Call this from your event handler to veto a system shutdown or to signal
2074 to the calling application that a window close did not happen.
2075 You can only veto a shutdown if CanVeto() returns
2078 void Veto(bool veto
= true);
2087 This class is used for a variety of menu-related events. Note that
2088 these do not include menu command events, which are
2089 handled using wxCommandEvent objects.
2091 The default handler for wxEVT_MENU_HIGHLIGHT displays help
2092 text in the first field of the status bar.
2097 @see @ref overview_wxcommandevent "Command events", @ref
2098 overview_eventhandlingoverview
2100 class wxMenuEvent
: public wxEvent
2106 wxMenuEvent(WXTYPE id
= 0, int id
= 0, wxMenu
* menu
= NULL
);
2109 Returns the menu which is being opened or closed. This method should only be
2110 used with the @c OPEN and @c CLOSE events and even for them the
2111 returned pointer may be @NULL in some ports.
2113 wxMenu
* GetMenu() const;
2116 Returns the menu identifier associated with the event. This method should be
2117 only used with the @c HIGHLIGHT events.
2119 int GetMenuId() const;
2122 Returns @true if the menu which is being opened or closed is a popup menu,
2123 @false if it is a normal one.
2124 This method should only be used with the @c OPEN and @c CLOSE events.
2126 bool IsPopup() const;
2132 @class wxEventBlocker
2135 This class is a special event handler which allows to discard
2136 any event (or a set of event types) directed to a specific window.
2142 // block all events directed to this window while
2143 // we do the 1000 FuncWhichSendsEvents() calls
2144 wxEventBlocker blocker(this);
2146 for ( int i = 0; i 1000; i++ )
2147 FuncWhichSendsEvents(i);
2149 } // ~wxEventBlocker called, old event handler is restored
2151 // the event generated by this call will be processed
2152 FuncWhichSendsEvents(0)
2158 @see @ref overview_eventhandlingoverview, wxEvtHandler
2160 class wxEventBlocker
: public wxEvtHandler
2164 Constructs the blocker for the given window and for the given event type.
2165 If @a type is @c wxEVT_ANY, then all events for that window are
2166 blocked. You can call Block() after creation to
2167 add other event types to the list of events to block.
2168 Note that the @a win window @b must remain alive until the
2169 wxEventBlocker object destruction.
2171 wxEventBlocker(wxWindow
* win
, wxEventType type
= wxEVT_ANY
);
2174 Destructor. The blocker will remove itself from the chain of event handlers for
2175 the window provided in the constructor, thus restoring normal processing of
2181 Adds to the list of event types which should be blocked the given @e eventType.
2183 void Block(wxEventType eventType
);
2192 A class that can handle events from the windowing system.
2193 wxWindow (and therefore all window classes) are derived from
2196 When events are received, wxEvtHandler invokes the method listed in the
2197 event table using itself as the object. When using multiple inheritance
2198 it is imperative that the wxEvtHandler(-derived) class be the first
2199 class inherited such that the "this" pointer for the overall object
2200 will be identical to the "this" pointer for the wxEvtHandler portion.
2205 @see @ref overview_eventhandlingoverview
2207 class wxEvtHandler
: public wxObject
2216 Destructor. If the handler is part of a chain, the destructor will
2217 unlink itself and restore the previous and next handlers so that they point to
2223 This function posts an event to be processed later.
2226 Event to add to process queue.
2228 @remarks The difference between sending an event (using the ProcessEvent
2229 method) and posting it is that in the first case the
2230 event is processed before the function returns, while
2231 in the second case, the function returns immediately
2232 and the event will be processed sometime later (usually
2233 during the next event loop iteration).
2235 virtual void AddPendingEvent(const wxEvent
& event
);
2239 Connects the given function dynamically with the event handler, id and event
2241 is an alternative to the use of static event tables. See the 'event' or the old
2242 'dynamic' sample for usage.
2245 The identifier (or first of the identifier range) to be
2246 associated with the event handler function. For the version not taking this
2247 argument, it defaults to wxID_ANY.
2249 The second part of the identifier range to be associated with the event
2252 The event type to be associated with this event handler.
2254 The event handler function. Note that this function should
2255 be explicitly converted to the correct type which can be done using a macro
2256 called wxFooEventHandler for the handler for any wxFooEvent.
2258 Data to be associated with the event table entry.
2260 Object whose member function should be called. If this is @NULL,
2263 void Connect(int id
, int lastId
, wxEventType eventType
,
2264 wxObjectEventFunction function
,
2265 wxObject
* userData
= NULL
,
2266 wxEvtHandler
* eventSink
= NULL
);
2267 void Connect(int id
, wxEventType eventType
,
2268 wxObjectEventFunction function
,
2269 wxObject
* userData
= NULL
,
2270 wxEvtHandler
* eventSink
= NULL
);
2271 void Connect(wxEventType eventType
,
2272 wxObjectEventFunction function
,
2273 wxObject
* userData
= NULL
,
2274 wxEvtHandler
* eventSink
= NULL
);
2279 Disconnects the given function dynamically from the event handler, using the
2281 parameters as search criteria and returning @true if a matching function has been
2282 found and removed. This method can only disconnect functions which have been
2284 using the Connect() method. There is no way
2285 to disconnect functions connected using the (static) event tables.
2288 The identifier (or first of the identifier range) associated with the event
2291 The second part of the identifier range associated with the event handler
2294 The event type associated with this event handler.
2296 The event handler function.
2298 Data associated with the event table entry.
2300 Object whose member function should be called.
2302 bool Disconnect(wxEventType eventType
= wxEVT_NULL
,
2303 wxObjectEventFunction function
= NULL
,
2304 wxObject
* userData
= NULL
,
2305 wxEvtHandler
* eventSink
= NULL
);
2306 bool Disconnect(int id
= wxID_ANY
,
2307 wxEventType eventType
= wxEVT_NULL
,
2308 wxObjectEventFunction function
= NULL
,
2309 wxObject
* userData
= NULL
,
2310 wxEvtHandler
* eventSink
= NULL
);
2311 bool Disconnect(int id
, int lastId
= wxID_ANY
,
2312 wxEventType eventType
= wxEVT_NULL
,
2313 wxObjectEventFunction function
= NULL
,
2314 wxObject
* userData
= NULL
,
2315 wxEvtHandler
* eventSink
= NULL
);
2319 Gets user-supplied client data.
2321 @remarks Normally, any extra data the programmer wishes to associate with
2322 the object should be made available by deriving a new
2323 class with new data members.
2325 @see SetClientData()
2327 void* GetClientData();
2330 Get a pointer to the user-supplied client data object.
2332 @see SetClientObject(), wxClientData
2334 wxClientData
* GetClientObject() const;
2337 Returns @true if the event handler is enabled, @false otherwise.
2339 @see SetEvtHandlerEnabled()
2341 bool GetEvtHandlerEnabled();
2344 Gets the pointer to the next handler in the chain.
2346 @see SetNextHandler(), GetPreviousHandler(),
2347 SetPreviousHandler(), wxWindow::PushEventHandler,
2348 wxWindow::PopEventHandler
2350 wxEvtHandler
* GetNextHandler();
2353 Gets the pointer to the previous handler in the chain.
2355 @see SetPreviousHandler(), GetNextHandler(),
2356 SetNextHandler(), wxWindow::PushEventHandler,
2357 wxWindow::PopEventHandler
2359 wxEvtHandler
* GetPreviousHandler();
2362 Processes an event, searching event tables and calling zero or more suitable
2363 event handler function(s).
2368 @returns @true if a suitable event handler function was found and
2369 executed, and the function did not call wxEvent::Skip.
2371 @remarks Normally, your application would not call this function: it is
2372 called in the wxWidgets implementation to dispatch
2373 incoming user interface events to the framework (and
2376 @see SearchEventTable()
2378 virtual bool ProcessEvent(wxEvent
& event
);
2381 Processes an event by calling ProcessEvent()
2382 and handles any exceptions that occur in the process. If an exception is
2383 thrown in event handler, wxApp::OnExceptionInMainLoop
2389 @returns @true if the event was processed, @false if no handler was found
2390 or an exception was thrown.
2392 @see wxWindow::HandleWindowEvent
2394 bool SafelyProcessEvent(wxEvent
& event
);
2397 Searches the event table, executing an event handler function if an appropriate
2402 Event table to be searched.
2404 Event to be matched against an event table entry.
2406 @returns @true if a suitable event handler function was found and
2407 executed, and the function did not call wxEvent::Skip.
2409 @remarks This function looks through the object's event table and tries
2410 to find an entry that will match the event.
2414 virtual bool SearchEventTable(wxEventTable
& table
,
2418 Sets user-supplied client data.
2421 Data to be associated with the event handler.
2423 @remarks Normally, any extra data the programmer wishes to associate with
2424 the object should be made available by deriving a new
2425 class with new data members. You must not call this
2426 method and SetClientObject on the same class - only one
2429 @see GetClientData()
2431 void SetClientData(void* data
);
2434 Set the client data object. Any previous object will be deleted.
2436 @see GetClientObject(), wxClientData
2438 void SetClientObject(wxClientData
* data
);
2441 Enables or disables the event handler.
2444 @true if the event handler is to be enabled, @false if it is to be disabled.
2446 @remarks You can use this function to avoid having to remove the event
2447 handler from the chain, for example when implementing a
2448 dialog editor and changing from edit to test mode.
2450 @see GetEvtHandlerEnabled()
2452 void SetEvtHandlerEnabled(bool enabled
);
2455 Sets the pointer to the next handler.
2458 Event handler to be set as the next handler.
2460 @see GetNextHandler(), SetPreviousHandler(),
2461 GetPreviousHandler(), wxWindow::PushEventHandler,
2462 wxWindow::PopEventHandler
2464 void SetNextHandler(wxEvtHandler
* handler
);
2467 Sets the pointer to the previous handler.
2470 Event handler to be set as the previous handler.
2472 void SetPreviousHandler(wxEvtHandler
* handler
);
2478 @class wxIconizeEvent
2481 An event being sent when the frame is iconized (minimized) or restored.
2483 Currently only wxMSW and wxGTK generate such events.
2488 @see @ref overview_eventhandlingoverview, wxTopLevelWindow::Iconize,
2489 wxTopLevelWindow::IsIconized
2491 class wxIconizeEvent
: public wxEvent
2497 wxIconizeEvent(int id
= 0, bool iconized
= true);
2500 Returns @true if the frame has been iconized, @false if it has been
2503 bool Iconized() const;
2512 A move event holds information about move change events.
2517 @see wxPoint, @ref overview_eventhandlingoverview
2519 class wxMoveEvent
: public wxEvent
2525 wxMoveEvent(const wxPoint
& pt
, int id
= 0);
2528 Returns the position of the window generating the move change event.
2530 wxPoint
GetPosition() const;
2539 An event is a structure holding information about an event passed to a
2540 callback or member function. @b wxEvent used to be a multipurpose
2541 event object, and is an abstract base class for other event classes (see below).
2543 For more information about events, see the @ref overview_eventhandlingoverview.
2545 @b wxPerl note: In wxPerl custom event classes should be derived from
2546 @c Wx::PlEvent and @c Wx::PlCommandEvent.
2551 @see wxCommandEvent, wxMouseEvent
2553 class wxEvent
: public wxObject
2557 Constructor. Should not need to be used directly by an application.
2559 wxEvent(int id
= 0, wxEventType eventType
= wxEVT_NULL
);
2562 Returns a copy of the event.
2563 Any event that is posted to the wxWidgets event system for later action (via
2564 wxEvtHandler::AddPendingEvent or
2565 wxPostEvent()) must implement this method. All wxWidgets
2566 events fully implement this method, but any derived events implemented by the
2567 user should also implement this method just in case they (or some event
2568 derived from them) are ever posted.
2569 All wxWidgets events implement a copy constructor, so the easiest way of
2570 implementing the Clone function is to implement a copy constructor for
2571 a new event (call it MyEvent) and then define the Clone function like this:
2573 virtual wxEvent
* Clone() const;
2576 Returns the object (usually a window) associated with the
2579 wxObject
* GetEventObject();
2582 Returns the identifier of the given event type,
2583 such as @c wxEVT_COMMAND_BUTTON_CLICKED.
2585 wxEventType
GetEventType();
2588 Returns the identifier associated with this event, such as a button command id.
2593 Returns @true if the event handler should be skipped, @false otherwise.
2595 bool GetSkipped() const;
2598 Gets the timestamp for the event. The timestamp is the time in milliseconds
2599 since some fixed moment (not necessarily the standard Unix Epoch, so
2600 only differences between the timestamps and not their absolute values usually
2603 long GetTimestamp();
2606 Returns @true if the event is or is derived from
2607 wxCommandEvent else it returns @false.
2608 Note: Exists only for optimization purposes.
2610 bool IsCommandEvent() const;
2613 Sets the propagation level to the given value (for example returned from an
2614 earlier call to wxEvent::StopPropagation).
2616 void ResumePropagation(int propagationLevel
);
2619 Sets the originating object.
2621 void SetEventObject(wxObject
* object
);
2624 Sets the event type.
2626 void SetEventType(wxEventType type
);
2629 Sets the identifier associated with this event, such as a button command id.
2634 Sets the timestamp for the event.
2636 void SetTimestamp(long timeStamp
);
2639 Test if this event should be propagated or not, i.e. if the propagation level
2640 is currently greater than 0.
2642 bool ShouldPropagate() const;
2645 This method can be used inside an event handler to control whether further
2646 event handlers bound to this event will be called after the current one
2647 returns. Without Skip() (or equivalently if Skip(@false) is used),
2648 the event will not be processed any more. If Skip(@true) is called, the event
2649 processing system continues searching for a further handler function for this
2650 event, even though it has been processed already in the current handler.
2651 In general, it is recommended to skip all non-command events to allow the
2652 default handling to take place. The command events are, however, normally not
2653 skipped as usually a single command such as a button click or menu item
2654 selection must only be processed by one handler.
2656 void Skip(bool skip
= true);
2659 Stop the event from propagating to its parent window.
2660 Returns the old propagation level value which may be later passed to
2661 ResumePropagation() to allow propagating the
2664 int StopPropagation();
2667 int m_propagationLevel
2668 Indicates how many levels the event can propagate. This member is protected and
2669 should typically only be set in the constructors of the derived classes. It
2670 may be temporarily changed by StopPropagation()
2671 and ResumePropagation() and tested with
2673 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by
2674 default) meaning that the event shouldn't be propagated at all or to
2675 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
2676 propagated as much as necessary.
2677 Any positive number means that the event should be propagated but no more than
2678 the given number of times. E.g. the propagation level may be set to 1 to
2679 propagate the event to its parent only, but not to its grandparent.
2689 A size event holds information about size change events.
2691 The EVT_SIZE handler function will be called when the window has been resized.
2693 You may wish to use this for frames to resize their child windows as
2696 Note that the size passed is of
2697 the whole window: call wxWindow::GetClientSize for the area which may be
2698 used by the application.
2700 When a window is resized, usually only a small part of the window is damaged
2702 may only need to repaint that area. However, if your drawing depends on the
2704 you may need to clear the DC explicitly and repaint the whole window. In which
2706 may need to call wxWindow::Refresh to invalidate the entire window.
2711 @see wxSize, @ref overview_eventhandlingoverview
2713 class wxSizeEvent
: public wxEvent
2719 wxSizeEvent(const wxSize
& sz
, int id
= 0);
2722 Returns the entire size of the window generating the size change event.
2724 wxSize
GetSize() const;
2730 @class wxSetCursorEvent
2733 A SetCursorEvent is generated when the mouse cursor is about to be set as a
2734 result of mouse motion. This event gives the application the chance to perform
2735 specific mouse cursor processing based on the current position of the mouse
2736 within the window. Use wxSetCursorEvent::SetCursor to
2737 specify the cursor you want to be displayed.
2742 @see ::wxSetCursor, wxWindow::wxSetCursor
2744 class wxSetCursorEvent
: public wxEvent
2748 Constructor, used by the library itself internally to initialize the event
2751 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0);
2754 Returns a reference to the cursor specified by this event.
2756 wxCursor
GetCursor() const;
2759 Returns the X coordinate of the mouse in client coordinates.
2761 wxCoord
GetX() const;
2764 Returns the Y coordinate of the mouse in client coordinates.
2766 wxCoord
GetY() const;
2769 Returns @true if the cursor specified by this event is a valid cursor.
2771 @remarks You cannot specify wxNullCursor with this event, as it is not
2772 considered a valid cursor.
2774 bool HasCursor() const;
2777 Sets the cursor associated with this event.
2779 void SetCursor(const wxCursor
& cursor
);
2784 // ============================================================================
2785 // Global functions/macros
2786 // ============================================================================
2788 /** @ingroup group_funcmacro_misc */
2792 In a GUI application, this function posts @a event to the specified @e dest
2793 object using wxEvtHandler::AddPendingEvent().
2795 Otherwise, it dispatches @a event immediately using
2796 wxEvtHandler::ProcessEvent(). See the respective documentation for details
2801 void wxPostEvent(wxEvtHandler
* dest
, wxEvent
& event
);