diff options
| author | Fabio Alessandrelli | 2018-01-12 02:53:35 +0100 |
|---|---|---|
| committer | Fabio Alessandrelli | 2018-02-23 13:01:28 +0100 |
| commit | ff122a7e1fe4e061e564978450ee8bf442247a36 (patch) | |
| tree | bb768170df1b3f5e283b3e03d216a2c38cc88d87 /scene/gui/option_button.cpp | |
| parent | 90b94498443f72e9c6b17f922a2eba8ce3f04d6b (diff) | |
| download | godot-ff122a7e1fe4e061e564978450ee8bf442247a36.tar.gz godot-ff122a7e1fe4e061e564978450ee8bf442247a36.tar.zst godot-ff122a7e1fe4e061e564978450ee8bf442247a36.zip | |
Add item_focused signal to OptionButton
And id_focused to Popupmenu.
Diffstat (limited to 'scene/gui/option_button.cpp')
| -rw-r--r-- | scene/gui/option_button.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 71c14810f..6e53f11b9 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -75,6 +75,10 @@ void OptionButton::_notification(int p_what) { } } +void OptionButton::_focused(int p_which) { + emit_signal("item_focused", p_which); +} + void OptionButton::_selected(int p_which) { int selid = -1; @@ -290,6 +294,7 @@ void OptionButton::get_translatable_strings(List<String> *p_strings) const { void OptionButton::_bind_methods() { ClassDB::bind_method(D_METHOD("_selected"), &OptionButton::_selected); + ClassDB::bind_method(D_METHOD("_focused"), &OptionButton::_focused); ClassDB::bind_method(D_METHOD("add_item", "label", "id"), &OptionButton::add_item, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id"), &OptionButton::add_icon_item); @@ -322,6 +327,7 @@ void OptionButton::_bind_methods() { // "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"))); + ADD_SIGNAL(MethodInfo("item_focused", PropertyInfo(Variant::INT, "ID"))); } OptionButton::OptionButton() { @@ -336,6 +342,7 @@ OptionButton::OptionButton() { popup->set_as_toplevel(true); popup->set_pass_on_modal_close_click(false); popup->connect("id_pressed", this, "_selected"); + popup->connect("id_focused", this, "_focused"); } OptionButton::~OptionButton() { |
