Skip to content

Commit

Permalink
Add a tabbed component on-tab right mouse popup lambda (#129)
Browse files Browse the repository at this point in the history
so you can do menus on the tabs. Defaults to null.
  • Loading branch information
baconpaul authored Sep 17, 2024
1 parent 0d7a2b1 commit 9944f20
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/sst/jucegui/components/TabbedComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,6 +174,7 @@ struct TabbedComponent : juce::TabbedComponent, style::StyleConsumer
}

void onStyleChanged() override { resized(); }
std::function<void(size_t)> onTabPopupMenu{nullptr};
};
} // namespace sst::jucegui::components
#endif // SHORTCIRCUITXT_TABBEDCOMPONENT_H

0 comments on commit 9944f20

Please sign in to comment.