6#include "TTauri/GUI/KeyboardKey.hpp"
7#include "TTauri/Text/Grapheme.hpp"
8#include "TTauri/Foundation/required.hpp"
9#include "TTauri/Foundation/assert.hpp"
14enum class KeyboardState : uint8_t {
21[[nodiscard]]
constexpr KeyboardState operator|(KeyboardState lhs, KeyboardState rhs)
noexcept {
22 return static_cast<KeyboardState
>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
25constexpr KeyboardState &operator|=(KeyboardState &lhs, KeyboardState rhs)
noexcept {
30[[nodiscard]]
constexpr bool operator>=(KeyboardState lhs, KeyboardState rhs)
noexcept {
31 ttlet lhs_ =
static_cast<uint8_t
>(lhs);
32 ttlet rhs_ =
static_cast<uint8_t
>(rhs);
33 return (lhs_ & rhs_) == rhs_;
38 enum class Type : uint8_t {
54 type(type), state(), grapheme(), key() {}
58 KeyboardEvent(KeyboardState state, KeyboardModifiers modifiers, KeyboardVirtualKey key) noexcept :
59 type(
Type::Key), state(state), grapheme(), key(modifiers, key) {}
64 [[nodiscard]]
static KeyboardEvent entered() noexcept {
68 [[nodiscard]]
static KeyboardEvent exited() noexcept {
74 [[nodiscard]] friend
std::
string to_string(KeyboardEvent const &rhs) noexcept {
78 case Type::Idle: r +=
"Idle";
break;
84 default: tt_no_default;
88 r += to_string(rhs.grapheme);
90 r += to_string(rhs.key);
98 return lhs << to_string(rhs);
Definition KeyboardEvent.hpp:37
Type
Definition KeyboardEvent.hpp:38
@ Grapheme
The user has finished entering a grapheme.
@ Exited
Keyboard focus was taken away.
@ Key
Key (+modifiers) was used to send a key.
@ Entered
Keyboard focus was given.
@ PartialGrapheme
The user is combining a grapheme.
KeyboardEvent(KeyboardState state, KeyboardModifiers modifiers, KeyboardVirtualKey key) noexcept
Create a key-key keyboard event.
Definition KeyboardEvent.hpp:58
A key in combination with modifiers.
Definition KeyboardKey.hpp:23
Definition Grapheme.hpp:20