diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/platform/gui/Keyboard.hpp | 3 | ||||
-rw-r--r-- | include/cru/ui/helper/ShortcutHub.hpp | 12 |
2 files changed, 10 insertions, 5 deletions
diff --git a/include/cru/platform/gui/Keyboard.hpp b/include/cru/platform/gui/Keyboard.hpp index 80524133..926b8d91 100644 --- a/include/cru/platform/gui/Keyboard.hpp +++ b/include/cru/platform/gui/Keyboard.hpp @@ -110,7 +110,8 @@ enum class KeyCode { NumPad9, LeftCommand, RightCommand, - Return + Return, + Space }; namespace details { diff --git a/include/cru/ui/helper/ShortcutHub.hpp b/include/cru/ui/helper/ShortcutHub.hpp index ed90381d..5b9612ba 100644 --- a/include/cru/ui/helper/ShortcutHub.hpp +++ b/include/cru/ui/helper/ShortcutHub.hpp @@ -49,7 +49,7 @@ class ShortcutKeyBind { return !this->operator==(other); } - String ToString() { + String ToString() const { String result = u"("; result += platform::gui::ToString(modifier_); result += u")"; @@ -61,6 +61,10 @@ class ShortcutKeyBind { platform::gui::KeyCode key_; platform::gui::KeyModifier modifier_; }; + +inline String ToString(const ShortcutKeyBind& key_bind) { + return key_bind.ToString(); +} } // namespace cru::ui::helper namespace std { @@ -78,7 +82,7 @@ struct hash<cru::ui::helper::ShortcutKeyBind> { namespace cru::ui::helper { struct Shortcut { // Just for debug. - std::u16string name; + String name; ShortcutKeyBind key_bind; // Return true if it consumes the shortcut. Or return false if it does not // handle the shortcut. @@ -87,7 +91,7 @@ struct Shortcut { struct ShortcutInfo { int id; - std::u16string name; + String name; ShortcutKeyBind key_bind; std::function<bool()> handler; }; @@ -101,7 +105,7 @@ class ShortcutHub : public Object { ~ShortcutHub() override = default; - int RegisterShortcut(std::u16string name, ShortcutKeyBind bind, + int RegisterShortcut(String name, ShortcutKeyBind bind, std::function<bool()> handler) { return RegisterShortcut({std::move(name), bind, std::move(handler)}); } |