The KeyEvent holds a pressed, released, or auto-repeated key event which occurs in the host operating system. More...
#include <kanzi/core.ui/platform/input/common/events.hpp>
Public Member Functions | |
| LogicalKey | getKey () const |
| Returns the LogicalKey value of the key event. More... | |
| LogicalKey | getKeyDown () const |
| Returns the logical key value of the key event if the event is in pressed state. More... | |
| LogicalKey | getKeyUp () const |
| Returns the logical key value of the key event if the event is in released state. More... | |
| KeyModifier | getModifiers () const |
| Returns the modifiers bitfields of the key event. More... | |
| size_t | getRawKey () const |
| Returns the raw key code of the event, or 0 if the event was created with no raw key code. More... | |
| KeyState | getState () const |
| Returns the state of the key event. More... | |
| string | getSymbol () const |
| Returns the symbol associated with the key event. More... | |
| bool | hasAltModifier () const |
| Checks whether the key event has any of the Alt key modifiers set. More... | |
| bool | hasCapsLock () const |
| Returns whether the key event is created with the KeyModifier::CapsLock modifier. More... | |
| bool | hasControlModifier () const |
| Checks whether the key event has any of the Control key modifiers set. More... | |
| bool | hasModifier (KeyModifier modifier) const |
| Checks whether the given modifier is set on the key event. More... | |
| bool | hasShiftModifier () const |
| Checks whether the key event has any of the Shift key modifiers set. More... | |
| bool | hasSuperModifier () const |
| Checks whether the key event has any of the Super key modifiers set. More... | |
| bool | isDown () const |
| Returns true if the key event represents a key down status, meaning it has Pressed status. More... | |
| bool | isTranslated () const |
| Returns true if the key event holds a translated operating system key event. More... | |
| bool | isUp () const |
| Returns true if the key event represents a key released status. More... | |
| KeyEvent (LogicalKey key, KeyModifier modifiers, KeyState state, string_view symbol) | |
| Creates a key event with a logical key, modifiers, state and localized key symbol. More... | |
| KeyEvent (size_t rawKeyCode, KeyState state, string_view symbol) | |
| Creates a key event with a rawKeyCode, state, and localized key symbol. More... | |
Public Member Functions inherited from kanzi::InputEvent | |
| Type | getType () const |
| Returns the type of the event. More... | |
| InputEvent (Type type) | |
| Constructs an event with a given type. More... | |
| bool | isHandled () const |
| Returns true if the event is handled, false if not. More... | |
| void | markHandled () |
| Marks teh event as handled. More... | |
| virtual | ~InputEvent () |
| Destructor. More... | |
Protected Attributes | |
| bool | m_capsLock |
| The Caps lock state. More... | |
| LogicalKey | m_key |
| The translated logical key code. More... | |
| KeyModifier | m_modifiers |
| The key modifier flags applied on the key stroke. More... | |
| size_t | m_rawKeyCode |
| The raw key code, an operating system specific value. More... | |
| KeyState | m_state |
| The key event state. More... | |
| string | m_text |
| The localized key symbol. More... | |
Additional Inherited Members | |
Public Types inherited from kanzi::InputEvent | |
| enum | Type { Key, Pointer, Touch, WindowResized, WindowResizeRequest, WindowFocusLost, WindowFocusGained, WindowHidden, WindowResourcesLost, WindowOrientationChanged, WindowRedrawRequest, WindowClosed, ApplicationPaused, ApplicationSleep, ApplicationWakeup, DebugToggleHud, DebugSetHud, UserEvent } |
| InputEvent type enumeration. More... | |
The KeyEvent holds a pressed, released, or auto-repeated key event which occurs in the host operating system.
Contains the logical key code translated from the raw operating system specific key code, the key modifiers, and the localized key symbol of the key.
Operating system adaptations must map the raw key code into a LogicalKey value, set the applicable key modifiers, and, if possible, provide the key symbol that maps the raw key code to the current hardware keyboard layout. Key symbols can be a result of consecutive key events, in which case the symbol is only reported at the last operating system key event that triggers the symbol. For example, this is the way to handle dead keys.
If the application does not detect any key modifiers or the modifier presented by the operating system does not match any modifier defined by Kanzi, set KeyModifier::Undefined.
When the operating system key code does not match any logical key defined in Kanzi, create the key event with the raw key code set. When you create a KeyEvent in this way, you tell Kanzi that the raw key code is the only valid information when handling the event.
The type of the event is InputEvent::Key.
|
explicit |
Creates a key event with a logical key, modifiers, state and localized key symbol.
The raw key code of the key event created in this way is set to 0.
| key | The logical key code of the event. |
| modifiers | The key modifiers accompanying the key event. |
| state | The key state. |
| symbol | The symbol associated with the key event. This can be a result of a set of consecutive key events, but reported by the operating system at this key event. |
|
explicit |
Creates a key event with a rawKeyCode, state, and localized key symbol.
Use this constructor when the raw key code does not map to any logical key code defined in Kanzi.
| rawKeyCode | The operating system specific raw key code. |
| state | The key state. |
| symbol | The symbol associated with the key event. This can be a result of a set of consecutive key events, but reported by the operating system at this key event. |
|
inline |
Returns the raw key code of the event, or 0 if the event was created with no raw key code.
Note that this method returns the value that is specific to the operating system.
|
inline |
Returns the LogicalKey value of the key event.
|
inline |
Returns the modifiers bitfields of the key event.
|
inline |
Returns the state of the key event.
|
inline |
Returns true if the key event represents a key down status, meaning it has Pressed status.
|
inline |
Returns true if the key event represents a key released status.
|
inline |
Returns the symbol associated with the key event.
|
inline |
Checks whether the given modifier is set on the key event.
|
inline |
Returns the logical key value of the key event if the event is in pressed state.
|
inline |
Returns the logical key value of the key event if the event is in released state.
|
inline |
Returns true if the key event holds a translated operating system key event.
| bool kanzi::KeyEvent::hasShiftModifier | ( | ) | const |
Checks whether the key event has any of the Shift key modifiers set.
| bool kanzi::KeyEvent::hasAltModifier | ( | ) | const |
Checks whether the key event has any of the Alt key modifiers set.
| bool kanzi::KeyEvent::hasControlModifier | ( | ) | const |
Checks whether the key event has any of the Control key modifiers set.
| bool kanzi::KeyEvent::hasSuperModifier | ( | ) | const |
Checks whether the key event has any of the Super key modifiers set.
|
inline |
Returns whether the key event is created with the KeyModifier::CapsLock modifier.
|
protected |
The localized key symbol.
Depending on the hardware mapping of the operating system this can be either a character or a string.
|
protected |
The key modifier flags applied on the key stroke.
|
protected |
The raw key code, an operating system specific value.
If you create the event with no raw key code, this value is 0.
|
protected |
The translated logical key code.
|
protected |
The key event state.
|
protected |
The Caps lock state.