Skip to content

Commit

Permalink
Merge pull request #54328 from YeldhamDev/tabbar_close_signal_rename
Browse files Browse the repository at this point in the history
Rename `TabBar`'s `tab_closed` signal to `tab_close_pressed`
  • Loading branch information
mhilbrunner authored Oct 29, 2021
2 parents 75baf16 + 4c563a5 commit 343414c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions doc/classes/TabBar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,19 @@
Emitted when a tab is clicked, even if it is the current tab.
</description>
</signal>
<signal name="tab_closed">
<signal name="tab_close_pressed">
<argument index="0" name="tab" type="int" />
<description>
Emitted when a tab is closed.
Emitted when a tab's close button is pressed.
[b]Note:[/b] Tabs are not removed automatically once the close button is pressed, this behaviour needs to be programmed manually. For example:
[codeblocks]
[gdscript]
$TabBar.tab_close_pressed.connect($TabBar.remove_tab)
[/gdscript]
[csharp]
GetNode&lt;TabBar&gt;("TabBar").TabClosePressed += GetNode&lt;TabBar&gt;("TabBar").RemoveTab;
[/csharp]
[/codeblocks]
</description>
</signal>
<signal name="tab_hovered">
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6227,7 +6227,7 @@ EditorNode::EditorNode() {
scene_tabs->set_drag_to_rearrange_enabled(true);
scene_tabs->connect("tab_changed", callable_mp(this, &EditorNode::_scene_tab_changed));
scene_tabs->connect("tab_rmb_clicked", callable_mp(this, &EditorNode::_scene_tab_script_edited));
scene_tabs->connect("tab_closed", callable_mp(this, &EditorNode::_scene_tab_closed), varray(SCENE_TAB_CLOSE));
scene_tabs->connect("tab_close_pressed", callable_mp(this, &EditorNode::_scene_tab_closed), varray(SCENE_TAB_CLOSE));
scene_tabs->connect("tab_hovered", callable_mp(this, &EditorNode::_scene_tab_hovered));
scene_tabs->connect("mouse_exited", callable_mp(this, &EditorNode::_scene_tab_exit));
scene_tabs->connect("gui_input", callable_mp(this, &EditorNode::_scene_tab_input));
Expand Down
4 changes: 2 additions & 2 deletions scene/gui/tab_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
if (cb_hover != -1) {
// pressed
emit_signal(SNAME("tab_closed"), cb_hover);
emit_signal(SNAME("tab_close_pressed"), cb_hover);
}

cb_pressing = false;
Expand Down Expand Up @@ -1172,7 +1172,7 @@ void TabBar::_bind_methods() {

ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_rmb_clicked", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_closed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_close_pressed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_hovered", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("active_tab_rearranged", PropertyInfo(Variant::INT, "idx_to")));
ADD_SIGNAL(MethodInfo("tab_clicked", PropertyInfo(Variant::INT, "tab")));
Expand Down

0 comments on commit 343414c

Please sign in to comment.