# Bug and potential fix: Button toggle disables tooltips

**URL:** <https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497>\
**Category:** General JUCE discussion\
**Created:** [August 22, 2021, 4:48pm UTC](https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497 "2021-08-22T16:48:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew0257](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@matthew0257](https://forum.juce.com/u/matthew0257)\
**Post date:** [August 22, 2021, 4:48pm UTC](https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497/1 "2021-08-22T16:48:52Z")

</div>

I recently encountered odd behavior with the interaction of tooltips and ToggleButtons (or any Button with click toggling enabled). Specifically, when I click on a ToggleButton that is currently in the “off” state, tooltips cease to appear.

After looking through the implementations of juce::Button and juce::TooltipWindow, it seems to be clear what is causing this.

juce\_Button.cpp  
_See image A_

The global modifiers are likely changed here so that any events triggered by setToggleState() will have the relevant modifiers, such as which mouse button _was_ used to click the Button, even though the mouse was already released at this point. The only issue is that the modifers are never reverted back to their _present_ state. Causing the following block of code to incorrectly be skipped:

juce\_TooltipWindow.cpp  
_See image B_

Because this issue is caused by the lack of anything changing the modifiers back to their present state, clicking anywhere will cause the tooltips to appear again.

Suggested fix:  
After changing the modifiers and setting the toggle state, return the modifiers to their correct state  
_See image C_

I can confirm that, after making this change locally, tooltips now appear as expected.

Image reference, to get around the maximum 1 upload requirement for new users:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/8/89adfa05eb3c4bfe9205c6a46d4a11c645a298d2.png)

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [August 23, 2021, 6:21pm UTC](https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497/2 "2021-08-23T18:21:08Z")

</div>

Could you describe in a bit more detail the behaviour you’d expect to see, and the behaviour that you actually see?

I tested this out in the “WidgetsDemo” in the demo runner. This demo has some buttons with tooltips which can be hovered and clicked. I tried running on both macOS Catalina and Windows 10.

When I hover one of the radio button checkboxes (which are ToggleButton instances), I see a tooltip appear. When I press and hold the mouse button on a button that is off, the tooltip disappears. When I release the mouse button, the tooltip reappears after a short delay. Does this match what you see? If not, please ensure that you’re running the latest version of JUCE from the develop branch and try testing again.

---

<div class="post-metadata">

**Author:** ![matthew0257](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@matthew0257](https://forum.juce.com/u/matthew0257)\
**Post date:** [August 23, 2021, 11:58pm UTC](https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497/3 "2021-08-23T23:58:25Z")

</div>

Hi reuk, it looks the “unfixed” code I had for juce\_Button.cpp never existed, and has always been the version that works correctly. Not sure how ModifierKeys::currentModifiers = modifiers got there. I don’t recall making any changes to it, but either way, the issue is solved now. Thanks for your patience and I’ll make sure to check the repository before posting in the future!

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [September 28, 2021, 1:30pm UTC](https://forum.juce.com/t/bug-and-potential-fix-button-toggle-disables-tooltips/47497/4 "2021-09-28T13:30:59Z")

</div>

To follow up - I’ve made a tiny tweak to the behaviour of the TooltipWindow so that it will only re-display after the mouse is moved. This more closely matches behaviour I see in other apps.

> <https://github.com/juce-framework/JUCE/commit/10a26b758471cdc68729eeb220bf72bd1edcb76e>
>
> This behaviour more closely mirrors the behaviour of other applications.
