summaryrefslogtreecommitdiff
path: root/scene/gui/menu_button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/menu_button.cpp')
-rw-r--r--scene/gui/menu_button.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 95ec618c3b..b67d8c00d6 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -71,13 +71,24 @@ PopupMenu *MenuButton::get_popup() const {
return popup;
}
+void MenuButton::_set_items(const Array &p_items) {
+
+ popup->set("items", p_items);
+}
+
Array MenuButton::_get_items() const {
return popup->get("items");
}
-void MenuButton::_set_items(const Array &p_items) {
- popup->set("items", p_items);
+void MenuButton::set_switch_on_hover(bool p_enabled) {
+
+ switch_on_hover = p_enabled;
+}
+
+bool MenuButton::is_switch_on_hover() {
+
+ return switch_on_hover;
}
void MenuButton::_bind_methods() {
@@ -86,9 +97,12 @@ 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_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover);
+ ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover);
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 | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover");
ADD_SIGNAL(MethodInfo("about_to_show"));
}
@@ -100,6 +114,7 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) {
MenuButton::MenuButton() {
+ switch_on_hover = false;
set_flat(true);
set_disable_shortcuts(false);
set_enabled_focus_mode(FOCUS_NONE);