aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Alekseev2018-02-16 11:29:19 +0300
committerHein-Pieter van Braam2018-02-19 22:29:36 +0100
commit18735ff6f2db987b799f252fb0716ecd23347d30 (patch)
treea71d30d01db908539934994db9bd44ac73a70bc9
parent237cf72f89251a385e7ee3805c55ffb4702adeed (diff)
downloadgodot-18735ff6f2db987b799f252fb0716ecd23347d30.tar.gz
godot-18735ff6f2db987b799f252fb0716ecd23347d30.tar.zst
godot-18735ff6f2db987b799f252fb0716ecd23347d30.zip
Fixes OptionButton selection index being reset to zero at instanciation
Bug: engine tries to set selected item before items were added during save scene/run project, because of wrong properties order. Fixes #10213. (cherry picked from commit 66c39b14261ee31244f864ebff7bdb6f3c55211f)
-rw-r--r--scene/gui/option_button.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 1a4692156..71c14810f 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -318,8 +318,9 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_items"), &OptionButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &OptionButton::_get_items);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "selected"), "_select_int", "get_selected");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
+ // "selected" property must come after "items", otherwise GH-10213 occurs
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "selected"), "_select_int", "get_selected");
ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "ID")));
}