buttonClicked() callback with mouse button differentiation


#1

Hi there,

i’ve got a component that listens to an imageButton and i’d like to do stuffs depending on whether the right or the left mouse button originated the buttonClicked() callback.
But i can’t find any way to get this information in buttonClicked() callback…

Did I miss something ?
What would be the most convenient way to do that ?

Thanx in advance !


#2

override

virtual void Button::clicked(const ModifierKeys & modifiers)

rather than the standard

virtual void Button::clicked()

ModifierKeys contains all kinds of useful stuff for you.


#3

Hi valley,

thanx for your answer.

In fact, rather than implementing my own button class (inheriting from juce::Button),
i was looking for a way to do that using ButtonListener and ButtonListener::buttonClicked (Button *button).

That’s maybe not a good idea :slight_smile:


#4

Best to avoid that kind of thing, because a button click could be triggered by other means - e.g. a key shortcut or programatically, so you shouldn’t always expect to get mouse info associated with it.


#5