1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:18:12 +00:00

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.
This commit is contained in:
Olivier De Cannière 2022-03-10 12:18:28 +01:00 committed by Andreas Kling
parent deef2911e9
commit da714f771d

View file

@ -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;
}
}