LibGUI: Allow double clicking on tabwidgets

This commit is contained in:
Erik Biederstadt 2021-11-30 09:42:13 -07:00 committed by Ali Mohammad Pur
parent 5ca242ce30
commit 0cfe446d3f
Notes: sideshowbarker 2024-07-17 23:17:41 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -635,6 +635,18 @@ void TabWidget::context_menu_event(ContextMenuEvent& context_menu_event)
}
}
void TabWidget::doubleclick_event(MouseEvent&)
{
for (auto& tab : m_tabs) {
if (auto* widget = tab.widget) {
deferred_invoke([this, widget] {
if (on_double_click)
on_double_click(*widget);
});
}
}
}
void TabWidget::set_container_margins(GUI::Margins const& margins)
{
m_container_margins = margins;

View file

@ -86,6 +86,7 @@ public:
Function<void(Widget&)> on_middle_click;
Function<void(Widget&)> on_tab_close_click;
Function<void(Widget&, const ContextMenuEvent&)> on_context_menu_request;
Function<void(Widget&)> on_double_click;
protected:
TabWidget();
@ -99,6 +100,7 @@ protected:
virtual void leave_event(Core::Event&) override;
virtual void keydown_event(KeyEvent&) override;
virtual void context_menu_event(ContextMenuEvent&) override;
virtual void doubleclick_event(MouseEvent&) override;
private:
Gfx::IntRect child_rect_for_size(const Gfx::IntSize&) const;