# buttonClicked() callback with mouse button differentiation

**URL:** <https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820>\
**Category:** General JUCE discussion\
**Created:** [June 21, 2007, 1:25pm UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820 "2007-06-21T13:25:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cylvoon](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@cylvoon](https://forum.juce.com/u/cylvoon)\
**Post date:** [June 21, 2007, 1:25pm UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820/1 "2007-06-21T13:25:10Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![valley](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@valley](https://forum.juce.com/u/valley)\
**Post date:** [June 21, 2007, 4:01pm UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820/2 "2007-06-21T16:01:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cylvoon](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@cylvoon](https://forum.juce.com/u/cylvoon)\
**Post date:** [June 22, 2007, 8:40am UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820/3 "2007-06-22T08:40:19Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 26, 2007, 10:50am UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820/4 "2007-06-26T10:50:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 3:22pm UTC](https://forum.juce.com/t/buttonclicked-callback-with-mouse-button-differentiation/1820/5 "2017-05-12T15:22:49Z")

</div>

Closed on May 12, 2017, 3:22pm UTC


