diff options
author | FalseHonesty <thefalsehonesty@gmail.com> | 2020-05-06 23:03:03 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-09 23:54:20 +0200 |
commit | bb6258229a0192b86ef68f3c7e2a7d135783a7de (patch) | |
tree | 70f7f9fb81e0fdfc953e4bcf137eba44470a5f69 /Libraries/LibGUI/TabWidget.cpp | |
parent | cbbfc08f1d991b4aec09130341681d21be8da117 (diff) | |
download | serenity-bb6258229a0192b86ef68f3c7e2a7d135783a7de.zip |
LibGUI: Add hook when a tab is middle clicked
Diffstat (limited to 'Libraries/LibGUI/TabWidget.cpp')
-rw-r--r-- | Libraries/LibGUI/TabWidget.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp index 61bf19863e..1f5e3e724e 100644 --- a/Libraries/LibGUI/TabWidget.cpp +++ b/Libraries/LibGUI/TabWidget.cpp @@ -236,7 +236,15 @@ void TabWidget::mousedown_event(MouseEvent& event) auto button_rect = this->button_rect(i); if (!button_rect.contains(event.position())) continue; - set_active_widget(m_tabs[i].widget); + if (event.button() == MouseButton::Left) { + set_active_widget(m_tabs[i].widget); + } else if (event.button() == MouseButton::Middle) { + auto* widget = m_tabs[i].widget; + deferred_invoke([this, widget](auto&) { + if (on_middle_click && widget) + on_middle_click(*widget); + }); + } return; } } |