diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-02-03 17:15:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 17:15:06 +0100 |
commit | 5e39a8eded8e3eba84ab9c74d31ba4aca6a235d2 (patch) | |
tree | 92ecb6b01b56eb6f8cc4bf7b3814bd2bd729fe12 /scene/gui/option_button.cpp | |
parent | 3004415bfc1cf53879729a3c5dd4185c51496973 (diff) | |
parent | 73c225838fa2e6f3ca3adf328375d1c659dc261b (diff) | |
download | redot-engine-5e39a8eded8e3eba84ab9c74d31ba4aca6a235d2.tar.gz |
Merge pull request #56992 from YeldhamDev/smarter_popmenu_focus
Diffstat (limited to 'scene/gui/option_button.cpp')
-rw-r--r-- | scene/gui/option_button.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index c80de04c01..9984ab240a 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -181,7 +181,14 @@ void OptionButton::pressed() { Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale(); popup->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y)); popup->set_size(Size2(size.width, 0)); - popup->set_current_index(current); + + // If not triggered by the mouse, start the popup with the checked item selected. + if (popup->get_item_count() > 0 && + ((get_action_mode() == ActionMode::ACTION_MODE_BUTTON_PRESS && Input::get_singleton()->is_action_just_pressed("ui_accept")) || + (get_action_mode() == ActionMode::ACTION_MODE_BUTTON_RELEASE && Input::get_singleton()->is_action_just_released("ui_accept")))) { + popup->set_current_index(current > -1 ? current : 0); + } + popup->popup(); } |