Godot Engine – Multi-platform 2D and 3D game engine
[TabBar] Fix tab selection sound playback for touch input
Anish Kumar23549e478ca7
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cppindex 4e5004a425c..4c1f7e81f69 100644--- a/scene/gui/tab_bar.cpp+++ b/scene/gui/tab_bar.cpp@@ -526,20 +526,23 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {play_theme_sound(theme_cache.pressed_sound);emit_signal(SNAME("tab_close_pressed"), cb_hover);}- } else if (tab_pressing != -1 && !tabs[tab_pressing].disabled) {+ } else if (tab_pressing != -1) {// Selecting a tab.int found = get_tab_idx_at_point(pos);- // Handle audio feedback separately, so that we can play the "disabled" sound when needed.- if (true) {- play_theme_sound(tabs[found].disabled ? theme_cache.pressed_disabled_sound : theme_cache.pressed_sound);- }if (found == tab_pressing) {- if (deselect_enabled && get_current_tab() == found) {- set_current_tab(-1);- } else {- set_current_tab(found);+ // Handle audio feedback separately, so that we can play the "disabled" sound when needed.+ if (current != found) {+ play_theme_sound(tabs[found].disabled ? theme_cache.pressed_disabled_sound : theme_cache.pressed_sound);+ }++ if (!tabs[tab_pressing].disabled) {+ if (deselect_enabled && current == found) {+ set_current_tab(-1);+ } else {+ set_current_tab(found);+ }+ emit_signal(SNAME("tab_clicked"), found);}- emit_signal(SNAME("tab_clicked"), found);}}}