From ea20049afc9dad1398e5cb8ffd3c0518f15d58bc Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 20 Mar 2022 06:57:28 +0000 Subject: Ensure minimum modifiers are pressed when matching actions --- core/input/input_event.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'core/input') 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 &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 &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(); -- cgit v1.2.3