diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-30 00:15:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-30 00:15:33 +0100 |
commit | cf67f18ce9277dce79c3e8b3f3223a1274d7868a (patch) | |
tree | 45e36584c7be9cafe64c3630701b9fda04266696 | |
parent | 03cfdf8cc7dd6923ebda22635c6e9dba98dd2a65 (diff) | |
parent | 8c2b7ea537e19d8c00dab10e1902f24fdd2c8e84 (diff) |
Merge pull request #55454 from ator-dev/block-hidden-tab-close-4.0
Prevent hidden tab close buttons from intercepting input [4.0]
-rw-r--r-- | scene/gui/tab_bar.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 57ee7fd494..c7d5a600a1 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -164,7 +164,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (rb_pressing && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { if (rb_hover != -1) { - // pressed + // Right mouse button clicked. emit_signal(SNAME("tab_rmb_clicked"), rb_hover); } @@ -174,7 +174,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { if (cb_hover != -1) { - // pressed + // Close button pressed. emit_signal(SNAME("tab_close_pressed"), cb_hover); } @@ -183,7 +183,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } if (mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || (select_with_rmb && mb->get_button_index() == MouseButton::RIGHT))) { - // clicks + // Clicks. Point2 pos = mb->get_position(); if (buttons_visible) { @@ -235,7 +235,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { return; } - if (tabs[i].cb_rect.has_point(pos)) { + if (tabs[i].cb_rect.has_point(pos) && (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current))) { cb_pressing = true; update(); return; @@ -659,7 +659,7 @@ void TabBar::_update_hover() { } const Point2 &pos = get_local_mouse_position(); - // test hovering to display right or close button + // test hovering to display right or close button. int hover_now = -1; int hover_buttons = -1; for (int i = offset; i < tabs.size(); i++) { @@ -684,7 +684,7 @@ void TabBar::_update_hover() { emit_signal(SNAME("tab_hovered"), hover); } - if (hover_buttons == -1) { // no hover + if (hover_buttons == -1) { // No hover. rb_hover = hover_buttons; cb_hover = hover_buttons; } @@ -860,7 +860,7 @@ bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const { if (from_path == to_path) { return true; } else if (get_tabs_rearrange_group() != -1) { - // drag and drop between other TabBars + // Drag and drop between other TabBars. Node *from_node = get_node(from_path); TabBar *from_tabs = Object::cast_to<TabBar>(from_node); if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) { @@ -895,7 +895,7 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { emit_signal(SNAME("active_tab_rearranged"), hover_now); set_current_tab(hover_now); } else if (get_tabs_rearrange_group() != -1) { - // drag and drop between Tabs + // Drag and drop between Tabs. Node *from_node = get_node(from_path); TabBar *from_tabs = Object::cast_to<TabBar>(from_node); if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) { |