diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 518c9778c0d..80810033209 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -184,6 +184,12 @@ + + + + Emitted when the active tab is rearranged via mouse drag. See [member drag_to_rearrange_enabled]. + + Emitted when the [TabContainer]'s [Popup] button is clicked. See [method set_popup] for details. @@ -201,6 +207,18 @@ Emitted when switching to another tab. + + + + Emitted when a tab is clicked, even if it is the current tab. + + + + + + Emitted when a tab is hovered by the mouse. + + diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index f8a55166f9e..818e19ab292 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -455,6 +455,7 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C move_child(get_tab_control(tab_from_id), get_tab_control(hover_now)->get_index(false)); if (!is_tab_disabled(hover_now)) { + emit_signal(SNAME("active_tab_rearranged"), hover_now); set_current_tab(hover_now); } @@ -499,6 +500,14 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C } } +void TabContainer::_on_tab_clicked(int p_tab) { + emit_signal(SNAME("tab_clicked"), p_tab); +} + +void TabContainer::_on_tab_hovered(int p_tab) { + emit_signal(SNAME("tab_hovered"), p_tab); +} + void TabContainer::_on_tab_changed(int p_tab) { call_deferred(SNAME("_repaint")); @@ -973,7 +982,10 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("_repaint"), &TabContainer::_repaint); ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed); + ADD_SIGNAL(MethodInfo("active_tab_rearranged", PropertyInfo(Variant::INT, "idx_to"))); ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); + ADD_SIGNAL(MethodInfo("tab_clicked", PropertyInfo(Variant::INT, "tab"))); + ADD_SIGNAL(MethodInfo("tab_hovered", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("tab_selected", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("tab_button_pressed", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("pre_popup_pressed")); @@ -994,6 +1006,8 @@ TabContainer::TabContainer() { add_child(tab_bar, false, INTERNAL_MODE_FRONT); tab_bar->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE); tab_bar->connect("tab_changed", callable_mp(this, &TabContainer::_on_tab_changed)); + tab_bar->connect("tab_clicked", callable_mp(this, &TabContainer::_on_tab_clicked)); + tab_bar->connect("tab_hovered", callable_mp(this, &TabContainer::_on_tab_hovered)); tab_bar->connect("tab_selected", callable_mp(this, &TabContainer::_on_tab_selected)); tab_bar->connect("tab_button_pressed", callable_mp(this, &TabContainer::_on_tab_button_pressed)); diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index f41aac6c293..711b57e4211 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -91,6 +91,8 @@ class TabContainer : public Container { void _update_margins(); void _on_mouse_exited(); void _on_tab_changed(int p_tab); + void _on_tab_clicked(int p_tab); + void _on_tab_hovered(int p_tab); void _on_tab_selected(int p_tab); void _on_tab_button_pressed(int p_tab);