aboutsummaryrefslogtreecommitdiff
path: root/src/ui/helper
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-26 19:39:24 +0800
committercrupest <crupest@outlook.com>2020-12-26 19:39:24 +0800
commit715be3c81b96fcf87c7650501d71480a8743a984 (patch)
treef56119db325f57280ab625cf1927b846e3eebdcb /src/ui/helper
parent61b835d47ab98279c5f2f43bebcd4fe18f7c408d (diff)
downloadcru-715be3c81b96fcf87c7650501d71480a8743a984.tar.gz
cru-715be3c81b96fcf87c7650501d71480a8743a984.tar.bz2
cru-715be3c81b96fcf87c7650501d71480a8743a984.zip
...
Diffstat (limited to 'src/ui/helper')
-rw-r--r--src/ui/helper/ShortcutHub.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ui/helper/ShortcutHub.cpp b/src/ui/helper/ShortcutHub.cpp
index 823072f2..f35ad0ef 100644
--- a/src/ui/helper/ShortcutHub.cpp
+++ b/src/ui/helper/ShortcutHub.cpp
@@ -85,6 +85,8 @@ void ShortcutHub::OnKeyDown(event::KeyEventArgs& event) {
ShortcutKeyBind key_bind(event.GetKeyCode(), event.GetKeyModifier());
const auto& shortcut_list = this->GetShortcutByKeyBind(key_bind);
+ bool handled = false;
+
if constexpr (debug_flags::shortcut) {
if (shortcut_list.empty()) {
log::Debug(u"No shortcut for key bind {}.", key_bind.ToString());
@@ -100,12 +102,13 @@ void ShortcutHub::OnKeyDown(event::KeyEventArgs& event) {
log::Debug(u"Handle {} handled it.", shortcut.name);
}
+ handled = true;
event.SetHandled();
break;
} else {
if constexpr (debug_flags::shortcut) {
- log::Debug(u"Handle {} disdn't handle it.", shortcut.name);
+ log::Debug(u"Handle {} didn't handle it.", shortcut.name);
}
}
}
@@ -116,5 +119,13 @@ void ShortcutHub::OnKeyDown(event::KeyEventArgs& event) {
key_bind.ToString());
}
}
+
+ if (!handled) {
+ if constexpr (debug_flags::shortcut) {
+ log::Debug(u"Raise fallback event for unhandled shortcut of key bind {}.",
+ key_bind.ToString());
+ }
+ fallback_event_.Raise(event);
+ }
}
} // namespace cru::ui::helper