Skip to content

Commit

Permalink
Merge pull request #55454 from ator-dev/block-hidden-tab-close-4.0
Browse files Browse the repository at this point in the history
Prevent hidden tab close buttons from intercepting input [4.0]
  • Loading branch information
akien-mga authored Nov 29, 2021
2 parents 03cfdf8 + 8c2b7ea commit cf67f18
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scene/gui/tab_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit cf67f18

Please sign in to comment.