[FR] Buttons: add option to ignore clicks with right mouse button

perphaps it should be implemented at the Component level, like setInterceptsMouseClicks.

I’m not a fan of this idea beacuse that would defeat the purpose of my original request: a button that should trigger its click events when left-clicked, but that should display a pop-up menu when right-clicked.

If such an hypotetical setInterceptRightClicks() were implemented at Component level, then it’d be impossible to receive right-clicks at all to trigger the menu.

Unless, right clicks were still forwarded to registered MouseListenersand only their “internal” handling were ignored, but that feels a little too “fragile” to be reliable

1 Like

Bump for an official response from the JUCE team?

1 Like

+1 please consider this. JUCE is the only UI system where buttons activate on right click. macOS, Windows, Linux, etc buttons do not activate on right click. And there is no easy way to work around this, I posted another FR to be able to get the ModifierKeys in onClick() so at least you could test if was a right click.


Ideally you’d want something like an event filter to intercept arbitrary events being passed to children. I think this is a much better request than a special case for ignoring clicks.

But either way you could have a pair of components, one as a container for the children whose events are intercepted and the context menu as a sibling of the container.

1 Like

Totally. It would add so much more flexibility to the Component system, especially with use cases like the one @RolandMR mentioned where you’d want to customize the events for a reusable Component like juce::Button for a specific use case.

I’ve been only been experimenting with it so far but the druid framework has an elegant way of doing this, where you can assign a Controller to widgets and use it to determine which events get passed on to its children. It would be very useful to have a similar abstraction in JUCE, when you don’t actually want to make a component, but encapsulate one and modify its behavior by intercepting events destined for its children. Something that makes that tricky in JUCE today is that it doesn’t have a generic event dispatch method, everything is a virtual method.