Key event: event when a key is pressed/released or when text in entered. More...
Public Member Functions | |
GEventState | state () const |
Returns an ORed combination of buttons and modifiers; see GEvent::States. | |
GKeyCode | key () const |
Returns the keycode of the key that was pressed or released. More... | |
GString const & | text () const |
Returns the entered text (in UTF8). More... | |
Gadget * | chosen () const |
Returns the checked child of a box that enforces exclusive selection. More... | |
GWindow * | window () const |
Returns the window where this event occured. | |
GTrigger const & | trigger () const |
Returns the trigger that fired this event. | |
GEventType | eventMask () const |
Returns the event mask. | |
int | channel () const |
Returns the input channel. More... | |
GTime | time () const |
Returns the timestamp. More... | |
void | postFire (std::function< void(GEvent &)> const &todo_after) |
Sets a function that is called after firing all callbacks trigerred by a same event. | |
int | matches (GTrigger const &trigger, int channel) const |
Returns a non-zero value if this trigger matches this event. | |
virtual GMouseEvent & | asMouseEvent () |
Returns the event casted to the specified event subclass. More... | |
virtual GMouseEvent * | toMouseEvent () |
Returns the event casted to the specified event subclass. More... | |
Gadget & | from () const |
Returns where this event occured. More... | |
GObject * | tag () const |
Changes/returns the event tag. More... | |
Static Public Member Functions | |
static GEventState | buttonToState (int mouse_button) |
Converts a mouse button number into an event state. More... | |
static GEventState | modifierToState (GKeyCode modifier_key) |
Converts a modifier keycode intoto an event state. | |
static GEventState | modifiersToStates (GString const &modifiers) |
Converts a combination of modifier names to ORed modifier states. More... | |
static void | setMouseButtonHandler (int channel, std::function< bool(class GMouseEvent &)>) |
Sets a global handler that intercepts all the the events of the specified type. More... | |
static GString | keyToName (GKeyCode key) |
Converts a key code into a key name and vice-versa. | |
Static Public Attributes | |
static const GKeyCode | EscapeKey = SDLK_ESCAPE |
Keycodes of special keys. More... | |
Key event: event when a key is pressed/released or when text in entered.
Corresponding triggers: GTrigger::keydown, keyup, type.
|
inline |
Returns the keycode of the key that was pressed or released.
may return 0 for on::keytype events.
|
inline |
Returns the entered text (in UTF8).
may return "" for on::keydown and on::keyup events or if a modifier was pressed (e.g. ctrl-K)
|
virtualinherited |
Returns the event casted to the specified event subclass.
Throws an exception that resets the event loop if the event does not derive from this subclass.
Reimplemented in guit::GMouseEvent.
|
inlinevirtualinherited |
Returns the event casted to the specified event subclass.
Returns null if if the event does not derive from this subclass.
Reimplemented in guit::GMouseEvent.
|
inherited |
Returns where this event occured.
|
inherited |
Returns the checked child of a box that enforces exclusive selection.
Returns null if N/A, and the same value as GChoiceBox::chosen() otherwise.
|
inlineinherited |
Returns the input channel.
Return 0 for system events, a value > 0 for other input channels (see GChannel).
|
inlineinherited |
Returns the timestamp.
The timestamp is only defined for mouse/finger/key events.
|
inlineinherited |
Changes/returns the event tag.
Can be useful when redirecting events (see GMouseEvent::redirectEvent) so that the gadget that redirects the event can pass data to the final receiver.
|
staticinherited |
Sets a global handler that intercepts all the the events of the specified type.
Events will then processed normally if the handler returns true, and ignored otherwise. Only one handler can be set for a given event type. Passing nullptr removes the corresponding handler.
|
staticinherited |
Converts a mouse button number into an event state.
mouse_button = 1 returns GEventState::Button1 (left button), 2 returns Button 2 (right button), 3 returns Button3 (middle button), etc.
|
staticinherited |
Converts a combination of modifier names to ORed modifier states.
Valid modifier names are: ctrl, shift, meta/cmd, alt, altgr, caps, num. They can be combined by adding a - or a + between them, e.g. ctrl-shift
|
staticinherited |
Keycodes of special keys.
GKeyEvent has a key() method that returns the keycode.