From 9944f20fbd1bafdda3d233aea91fb79985262203 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 17 Sep 2024 09:13:44 -0400 Subject: [PATCH] Add a tabbed component on-tab right mouse popup lambda (#129) so you can do menus on the tabs. Defaults to null. --- .../sst/jucegui/components/TabbedComponent.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/sst/jucegui/components/TabbedComponent.h b/include/sst/jucegui/components/TabbedComponent.h index db0d5a6..4211013 100644 --- a/include/sst/jucegui/components/TabbedComponent.h +++ b/include/sst/jucegui/components/TabbedComponent.h @@ -125,6 +125,23 @@ struct TabbedComponent : juce::TabbedComponent, style::StyleConsumer hover = false; repaint(); } + void mouseDown(const juce::MouseEvent &event) override + { + if (event.mods.isPopupMenu() && parentComp->onTabPopupMenu) + { + parentComp->onTabPopupMenu(idx); + return; + } + juce::TabBarButton::mouseDown(event); + } + void mouseUp(const juce::MouseEvent &event) override + { + if (event.mods.isPopupMenu() && parentComp->onTabPopupMenu) + { + return; + } + juce::TabBarButton::mouseUp(event); + } public: int getBestTabLength(int depth) override @@ -157,6 +174,7 @@ struct TabbedComponent : juce::TabbedComponent, style::StyleConsumer } void onStyleChanged() override { resized(); } + std::function onTabPopupMenu{nullptr}; }; } // namespace sst::jucegui::components #endif // SHORTCIRCUITXT_TABBEDCOMPONENT_H