summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp3
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/shortcut.cpp8
3 files changed, 11 insertions, 2 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 82f4a216b8..871ad889ca 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -145,6 +145,9 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
if (status.press_attempt && status.pressing_inside) {
if (toggle_mode) {
+ if (Object::cast_to<InputEventShortcut>(*p_event)) {
+ action_mode = ACTION_MODE_BUTTON_PRESS; // HACK.
+ }
if ((p_event->is_pressed() && action_mode == ACTION_MODE_BUTTON_PRESS) || (!p_event->is_pressed() && action_mode == ACTION_MODE_BUTTON_RELEASE)) {
if (action_mode == ACTION_MODE_BUTTON_PRESS) {
status.press_attempt = false;
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index cf1f41d0fc..63b5793b3e 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -44,7 +44,7 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
return;
}
- if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
+ if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event) || Object::cast_to<InputEventShortcut>(*p_event))) {
if (!get_parent() || !is_visible_in_tree() || is_disabled()) {
return;
}
diff --git a/scene/gui/shortcut.cpp b/scene/gui/shortcut.cpp
index 885a51e058..1c29870682 100644
--- a/scene/gui/shortcut.cpp
+++ b/scene/gui/shortcut.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "shortcut.h"
-
#include "core/os/keyboard.h"
void Shortcut::set_event(const Ref<InputEvent> &p_event) {
+ ERR_FAIL_COND(Object::cast_to<InputEventShortcut>(*p_event));
event = p_event;
emit_changed();
}
@@ -42,6 +42,12 @@ Ref<InputEvent> Shortcut::get_event() const {
}
bool Shortcut::matches_event(const Ref<InputEvent> &p_event) const {
+ Ref<InputEventShortcut> ies = p_event;
+ if (ies != nullptr) {
+ if (ies->get_shortcut().ptr() == this) {
+ return true;
+ }
+ }
return event.is_valid() && event->is_match(p_event, true);
}