From fde24556042b76863bdec34dcc213cb7298f68f9 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Oct 2020 16:17:20 +0800 Subject: ... --- include/cru/platform/native/Keyboard.hpp | 5 +++++ include/cru/ui/ShortcutHub.hpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) (limited to 'include/cru') diff --git a/include/cru/platform/native/Keyboard.hpp b/include/cru/platform/native/Keyboard.hpp index 83c61bcc..8f53c5d6 100644 --- a/include/cru/platform/native/Keyboard.hpp +++ b/include/cru/platform/native/Keyboard.hpp @@ -1,4 +1,5 @@ #pragma once +#include #include "cru/common/Bitmask.hpp" namespace cru::platform::native { @@ -117,4 +118,8 @@ struct KeyModifiers { static constexpr KeyModifier ctrl{0b10}; static constexpr KeyModifier alt{0b100}; }; + +std::u16string_view ToString(KeyCode key_code); +std::u16string ToString(KeyModifier key_modifier, + std::u16string_view separator = u"+"); } // namespace cru::platform::native diff --git a/include/cru/ui/ShortcutHub.hpp b/include/cru/ui/ShortcutHub.hpp index 7557b758..a1dfcb7d 100644 --- a/include/cru/ui/ShortcutHub.hpp +++ b/include/cru/ui/ShortcutHub.hpp @@ -4,6 +4,7 @@ #include "cru/common/Base.hpp" #include "cru/common/Event.hpp" #include "cru/platform/native/Keyboard.hpp" +#include "cru/ui/UiEvent.hpp" #include #include @@ -43,6 +44,14 @@ class ShortcutKeyBind { return !this->operator==(other); } + std::u16string ToString() { + std::u16string result = u"("; + result += platform::native::ToString(modifier_); + result += u")"; + result += platform::native::ToString(key_); + return result; + } + private: platform::native::KeyCode key_; platform::native::KeyModifier modifier_; @@ -94,6 +103,9 @@ class ShortcutHub : public Object { void Install(Control* control); void Uninstall(); + private: + void OnKeyDown(event::KeyEventArgs& event); + private: std::unordered_map> map_; -- cgit v1.2.3