diff options
author | Olivier De Cannière <icristalrope@gmail.com> | 2022-03-10 12:18:28 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-16 14:25:47 +0100 |
commit | da714f771d2a164aca529e72207c80409b38d7b1 (patch) | |
tree | c5f2ee54963c701c106d8d3feb199db7426f6fbc /Userland/Libraries | |
parent | deef2911e909b5f6004f959ac8793746dd74a699 (diff) | |
download | serenity-da714f771d2a164aca529e72207c80409b38d7b1.zip |
LibGUI: Make only the targeted tab of TabWidget respond to double click
Previously, when double clicking on the tab bar, all tabs would respond
to the double click even if they weren't clicked on.
This issue, for example, prevented renaming of individual tabs in
Spreadsheet and instead asked the user to rename all tabs one by one.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/TabWidget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index f9f6e23aa9..26e7a9f90e 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -632,15 +632,19 @@ void TabWidget::context_menu_event(ContextMenuEvent& context_menu_event) } } -void TabWidget::doubleclick_event(MouseEvent&) +void TabWidget::doubleclick_event(MouseEvent& mouse_event) { - for (auto& tab : m_tabs) { - if (auto* widget = tab.widget) { + for (size_t i = 0; i < m_tabs.size(); ++i) { + auto button_rect = this->button_rect(i); + if (!button_rect.contains(mouse_event.position())) + continue; + if (auto* widget = m_tabs[i].widget) { deferred_invoke([this, widget] { if (on_double_click) on_double_click(*widget); }); } + return; } } |