summaryrefslogtreecommitdiff
path: root/scene/gui/menu_button.cpp
diff options
context:
space:
mode:
authorNoshyaar <poommetee@protonmail.com>2017-12-25 08:42:31 +0700
committerGitHub <noreply@github.com>2017-12-25 08:42:31 +0700
commit256a60bc6e05468ba64729f3d972086ab8ae95b5 (patch)
tree8b41047755ead177eec7f33f6227bb34e3d20837 /scene/gui/menu_button.cpp
parentaecffd71d89af9ab8c9b6dc737380b3c4e005330 (diff)
parent49859871d92c1540fa576dcd0e6d337840ab18e2 (diff)
Merge pull request #14826 from carlosfvieira/14371-F_key_Viewport_focus_problem
Fix spatial editor plugin issues on multi viewport view menu shortcuts (only those that are bound to keys)
Diffstat (limited to 'scene/gui/menu_button.cpp')
-rw-r--r--scene/gui/menu_button.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index d850553957..1d18c6504c 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -33,6 +33,9 @@
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
+ if (disable_shortcuts)
+ 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 (!get_parent() || !is_visible_in_tree() || is_disabled())
@@ -98,14 +101,22 @@ void MenuButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &MenuButton::_get_items);
+ ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_items", "_get_items");
ADD_SIGNAL(MethodInfo("about_to_show"));
}
+
+void MenuButton::set_disable_shortcuts(bool p_disabled) {
+
+ disable_shortcuts = p_disabled;
+}
+
MenuButton::MenuButton() {
set_flat(true);
+ set_disable_shortcuts(false);
set_enabled_focus_mode(FOCUS_NONE);
popup = memnew(PopupMenu);
popup->hide();