the chain until the event is processed or the chain is exhausted.
This function is called from ProcessEvent() and, in turn, calls
- TryThis() for each handler in turn. It is not virtual and so cannot be
+ TryBefore() and TryAfter(). It is not virtual and so cannot be
overridden but can, and should, be called to forward an event to
another handler instead of ProcessEvent() which would result in a
duplicate call to TryAfter(), e.g. resulting in all unprocessed events
*/
virtual bool TryBefore(wxEvent& event);
- /**
- Try to process the event in this event handler.
-
- This method is called from ProcessEventLocally() and thus, indirectly,
- from ProcessEvent(), please see the detailed description of the event
- processing logic there.
-
- It is currently @em not virtual and so may not be overridden.
-
- @since 2.9.1
-
- @param event
- Event to process.
- @return
- @true if this object itself defines a handler for this event and
- the handler didn't skip the event.
- */
- bool TryThis(wxEvent& event);
-
/**
Method called by ProcessEvent() as last resort.
codes.
Note that this method returns a meaningful value only for special
- non-alphanumeric keys or if the user entered a character that can be
- represented in current locale's default charset. Otherwise, e.g. if the
- user enters a Japanese character in a program not using Japanese
- locale, this method returns @c WXK_NONE and GetUnicodeKey() should be
- used to obtain the corresponding Unicode character.
+ non-alphanumeric keys or if the user entered a Latin-1 character (this
+ includes ASCII and the accented letters found in Western European
+ languages but not letters of other alphabets such as e.g. Cyrillic).
+ Otherwise it simply method returns @c WXK_NONE and GetUnicodeKey()
+ should be used to obtain the corresponding Unicode character.
Using GetUnicodeKey() is in general the right thing to do if you are
interested in the characters typed by the user, GetKeyCode() should be
@code
void MyHandler::OnChar(wxKeyEvent& event)
{
- if ( event.GetUnicodeKey() != WXK_NONE )
+ wxChar uc = event.GetUnicodeKey();
+ if ( uc != WXK_NONE )
{
- // It's a printable character
- wxLogMessage("You pressed '%c'", event.GetUnicodeKey());
+ // It's a "normal" character. Notice that this includes
+ // control characters in 1..31 range, e.g. WXK_RETURN or
+ // WXK_BACK, so check for them explicitly.
+ if ( uc >= 32 )
+ {
+ wxLogMessage("You pressed '%c'", uc);
+ }
+ else
+ {
+ // It's a control character
+ ...
+ }
}
- else
+ else // No Unicode equivalent.
{
// It's a special key, deal with all the known ones:
- switch ( keycode )
+ switch ( GetKeyCode() )
{
case WXK_LEFT:
case WXK_RIGHT:
//@{
/**
Obtains the position (in client coordinates) at which the key was pressed.
+
+ Notice that this position is simply the current mouse pointer position
+ and has no special relationship to the key event itself.
*/
wxPoint GetPosition() const;
void GetPosition(long* x, long* y) const;
/**
Returns the X position (in client coordinates) of the event.
+
+ @see GetPosition()
*/
wxCoord GetX() const;
/**
Returns the Y position (in client coordinates) of the event.
+
+ @see GetPosition()
*/
wxCoord GetY() const;
text was copied or cut.
@note
- These events are currently only generated by wxTextCtrl under GTK+.
- They are generated by all controls under Windows.
+ These events are currently only generated by wxTextCtrl in wxGTK and wxOSX
+ but are also generated by wxComboBox without wxCB_READONLY style in wxMSW.
@beginEventTable{wxClipboardTextEvent}
@event{EVT_TEXT_COPY(id, func)}
wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
};
+/**
+ Possible axis values for mouse wheel scroll events.
+
+ @since 2.9.4
+ */
+enum wxMouseWheelAxis
+{
+ wxMOUSE_WHEEL_VERTICAL, ///< Vertical scroll event.
+ wxMOUSE_WHEEL_HORIZONTAL ///< Horizontal scroll event.
+};
/**
int GetWheelRotation() const;
/**
- Gets the axis the wheel operation concerns; @c 0 is the Y axis as on
- most mouse wheels, @c 1 is the X axis.
+ Gets the axis the wheel operation concerns.
+
+ Usually the mouse wheel is used to scroll vertically so @c
+ wxMOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads)
+ also allow to use the wheel to scroll horizontally in which case
+ @c wxMOUSE_WHEEL_HORIZONTAL is returned.
- Note that only some models of mouse have horizontal wheel axis.
+ Notice that before wxWidgets 2.9.4 this method returned @c int.
*/
- int GetWheelAxis() const;
+ wxMouseWheelAxis GetWheelAxis() const;
/**
Returns @true if the event was a mouse button event (not necessarily a button
wxClientData* GetClientObject() const;
/**
- Returns extra information dependant on the event objects type.
+ Returns extra information dependent on the event objects type.
If the event comes from a listbox selection, it is a boolean
determining whether the event was a selection (@true) or a
window (whether using the mouse or keyboard) and when it is done from the
program itself using wxWindow::SetFocus.
+ The focus event handlers should almost invariably call wxEvent::Skip() on
+ their event argument to allow the default handling to take place. Failure
+ to do this may result in incorrect behaviour of the native controls. Also
+ note that wxEVT_KILL_FOCUS handler must not call wxWindow::SetFocus() as
+ this, again, is not supported by all native controls. If you need to do
+ this, consider using the @ref sec_delayed_action described in wxIdleEvent
+ documentation.
+
@beginEventTable{wxFocusEvent}
@event{EVT_SET_FOCUS(func)}
Process a @c wxEVT_SET_FOCUS event.
(and especially the first one) increase the system load and so should be avoided
if possible.
- By default, idle events are sent to all windows (and also wxApp, as usual).
- If this is causing a significant overhead in your application, you can call
- wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the
- wxWS_EX_PROCESS_IDLE extra window style for every window which should receive
- idle events.
+ By default, idle events are sent to all windows, including even the hidden
+ ones because they may be shown if some condition is met from their @c
+ wxEVT_IDLE (or related @c wxEVT_UPDATE_UI) handler. The children of hidden
+ windows do not receive idle events however as they can't change their state
+ in any way noticeable by the user. Finally, the global wxApp object also
+ receives these events, as usual, so it can be used for any global idle time
+ processing.
+
+ If sending idle events to all windows is causing a significant overhead in
+ your application, you can call wxIdleEvent::SetMode with the value
+ wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra window
+ style for every window which should receive idle events, all the other ones
+ will not receive them in this case.
@beginEventTable{wxIdleEvent}
@event{EVT_IDLE(func)}
@library{wxbase}
@category{events}
+ @section sec_delayed_action Delayed Action Mechanism
+
+ wxIdleEvent can be used to perform some action "at slightly later time".
+ This can be necessary in several circumstances when, for whatever reason,
+ something can't be done in the current event handler. For example, if a
+ mouse event handler is called with the mouse button pressed, the mouse can
+ be currently captured and some operations with it -- notably capturing it
+ again -- might be impossible or lead to undesirable results. If you still
+ want to capture it, you can do it from @c wxEVT_IDLE handler when it is
+ called the next time instead of doing it immediately.
+
+ This can be achieved in two different ways: when using static event tables,
+ you will need a flag indicating to the (always connected) idle event
+ handler whether the desired action should be performed. The originally
+ called handler would then set it to indicate that it should indeed be done
+ and the idle handler itself would reset it to prevent it from doing the
+ same action again.
+
+ Using dynamically connected event handlers things are even simpler as the
+ original event handler can simply wxEvtHandler::Connect() or
+ wxEvtHandler::Bind() the idle event handler which would only be executed
+ then and could wxEvtHandler::Disconnect() or wxEvtHandler::Unbind() itself.
+
+
@see @ref overview_events, wxUpdateUIEvent, wxWindow::OnInternalIdle
*/
class wxIdleEvent : public wxEvent
wxEventType wxEVT_HELP;
wxEventType wxEVT_DETAILED_HELP;
wxEventType wxEVT_COMMAND_TEXT_UPDATED;
+wxEventType wxEVT_COMMAND_TEXT_ENTER;
wxEventType wxEVT_COMMAND_TOOL_CLICKED;
wxEventType wxEVT_WINDOW_MODAL_DIALOG_CLOSED;