diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:16 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:16 -0600 |
commit | b1526f45b8e9b8cdbb6b799bdba84775694e8d0e (patch) | |
tree | c06975aebc6527a3eac06688c2ddd57c2cc2d215 /scene/gui | |
parent | aa6aa45675d7a242f2d24c188382c9a859de67e5 (diff) | |
parent | a328952fc16f18b6bbfade6d6888f1bd8690622e (diff) | |
download | redot-engine-b1526f45b8e9b8cdbb6b799bdba84775694e8d0e.tar.gz |
Merge pull request #97890 from timothyqiu/id-focused
Fix `PopupMenu.id_focused` signal using index as ID
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/option_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/popup_menu.cpp | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 79018c40f5..26d164a62d 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -178,7 +178,7 @@ bool OptionButton::_set(const StringName &p_name, const Variant &p_value) { } void OptionButton::_focused(int p_which) { - emit_signal(SNAME("item_focused"), p_which); + emit_signal(SNAME("item_focused"), popup->get_item_index(p_which)); } void OptionButton::_selected(int p_which) { diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 3c04094526..f6ebcc854c 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -474,7 +474,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = search_from; i < items.size(); i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -488,7 +488,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = 0; i < search_from; i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -512,7 +512,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = search_from; i >= 0; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -526,7 +526,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { for (int i = items.size() - 1; i >= search_from; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -692,7 +692,7 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) { if (items[i].text.findn(search_string) == 0) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); set_input_as_handled(); @@ -1091,7 +1091,7 @@ void PopupMenu::_notification(int p_what) { for (int i = search_from; i < items.size(); i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); match_found = true; @@ -1104,7 +1104,7 @@ void PopupMenu::_notification(int p_what) { for (int i = 0; i < search_from; i++) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); break; @@ -1124,7 +1124,7 @@ void PopupMenu::_notification(int p_what) { for (int i = search_from; i >= 0; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); match_found = true; @@ -1137,7 +1137,7 @@ void PopupMenu::_notification(int p_what) { for (int i = items.size() - 1; i >= search_from; i--) { if (!items[i].separator && !items[i].disabled) { mouse_over = i; - emit_signal(SNAME("id_focused"), i); + emit_signal(SNAME("id_focused"), items[i].id); scroll_to_item(i); control->queue_redraw(); break; |