summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2022-03-20 06:57:28 +0000
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2022-03-20 08:02:54 +0000
commitea20049afc9dad1398e5cb8ffd3c0518f15d58bc (patch)
tree3899b2f6d3043ff77a93abb10034de74aca83c3f /core/input
parent288cdca71d838806469dd4f277beb3f2c45e49d3 (diff)
Ensure minimum modifiers are pressed when matching actions
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input_event.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index ab0f36132f..52c7c69315 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -424,8 +424,13 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma
} else {
match = get_physical_keycode() == key->get_physical_keycode();
}
+ Key action_mask = get_modifiers_mask();
+ Key key_mask = key->get_modifiers_mask();
+ if (key->is_pressed()) {
+ match &= (action_mask & key_mask) == action_mask;
+ }
if (p_exact_match) {
- match &= get_modifiers_mask() == key->get_modifiers_mask();
+ match &= action_mask == key_mask;
}
if (match) {
bool pressed = key->is_pressed();
@@ -589,8 +594,13 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool p_
}
bool match = button_index == mb->button_index;
+ Key action_mask = get_modifiers_mask();
+ Key button_mask = mb->get_modifiers_mask();
+ if (mb->is_pressed()) {
+ match &= (action_mask & button_mask) == action_mask;
+ }
if (p_exact_match) {
- match &= get_modifiers_mask() == mb->get_modifiers_mask();
+ match &= action_mask == button_mask;
}
if (match) {
bool pressed = mb->is_pressed();