aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-11-15 17:19:09 +0800
committercrupest <crupest@outlook.com>2021-11-15 17:19:09 +0800
commite78a49111f454a8cdee180f5089e138d94416597 (patch)
tree94fe4fbfdebc54c37941a17e32c0f04799108d66 /include/cru/ui
parent4ac58d91bac0cebe2bdf5e11b9d63b9c41e6b39e (diff)
downloadcru-e78a49111f454a8cdee180f5089e138d94416597.tar.gz
cru-e78a49111f454a8cdee180f5089e138d94416597.tar.bz2
cru-e78a49111f454a8cdee180f5089e138d94416597.zip
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/helper/ShortcutHub.hpp12
1 files changed, 8 insertions, 4 deletions
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)});
}