# Problems with custom tooltip method, ComboBox

**URL:** <https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007>\
**Category:** General JUCE discussion\
**Created:** [March 10, 2010, 10:13am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007 "2010-03-10T10:13:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [March 10, 2010, 10:13am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/1 "2010-03-10T10:13:23Z")

</div>

I’m having an issue with my custom tooltip method. It is pretty simple: if isMouseOver() is true for a given component, I get the tooltip text for that component, and draw it in the desired location. This works great for my sliders and buttons, but seems to fail on my ComboBox, and on the label next to that combo box for some reason. The code I am using:

`if (syncComboBox->isMouseOver())
	{
		localTooltipText = syncComboBox->getTooltip();
		currentTooltipState = 8;
	}
	else if (syncLabel->isMouseOver())
	{
		localTooltipText = syncLabel->getTooltip();
		currentTooltipState = 9;`

The standard Juce tooltip window seems to work fine with the combo box and its associated label, but my tooltip code doesn’t seem to find them. If I wiggle the mouse around enough and do some weird voodoo (like mouse down on a slider, drag to over the label, mouse up), my tooltips will show. But they are “sticky” - they are hard to get going, and stay around for a weird amount of time.

Any idea what might be going on here? This is literally my final bug before release, after climbing over a mountain of bugs the last few months. HELP!!!

Thanks,

Sean Costello

---

<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:** [March 10, 2010, 10:21am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/2 "2010-03-10T10:21:10Z")

</div>

Well, yes - the combobox contains other components, and I guess the mouse is over them, not the combobox itself. Look at the way the tooltipwindow does it, for a smarter way to approach the problem.

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [March 10, 2010, 11:43am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/3 "2010-03-10T11:43:39Z")

</div>

OK, I have it mostly figured out. Here’s my new code:

[code]Component\* const newComp = Component::getComponentUnderMouse();  
const String newTip (getTipFor (newComp));

```
const bool componentChanged = (newComp != lastComponentUnderMouse);
lastComponentUnderMouse = newComp;

if(componentChanged)
{
	localTooltipText = newTip;
	triggerRepaint = true;
}
else
{
	triggerRepaint = false;
}

```

[/code]

My only problem now is that the tooltip sticks around if I move the mouse below my sliders or combo box. If I move above or to either side of the control in question, things work fine. Any idea what might be causing this? (I should note that the area below the sliders and combo box is where I am drawing my tooltip text.)

Thanks,

Sean Costello

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [March 11, 2010, 10:24pm UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/4 "2010-03-11T22:24:26Z")

</div>

I switched back to my old method, as it was more reliable than what I posted. It still doesn’t work for ComboBox. I understand that ComboBox has a bunch of Components in it, but shouldn’t isMouseOver() recognize that these are all part of the same ComboBox component? Or is there some other, non-convoluted method for recognizing that the mouse is over a Component built of other components?

Sean

---

<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:** [March 12, 2010, 9:44am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/5 "2010-03-12T09:44:56Z")

</div>

Your original snippet is a truly awful piece of hackery - don’t go back to it! Your second idea is fine, as long as you get the logic right, which probably just requires a few tweaks.

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [March 12, 2010, 11:15am UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/6 "2010-03-12T11:15:45Z")

</div>

Oh, so you think THAT was hackery? You ain’t seen NOTHIN’ yet!

---

<div class="post-metadata">

**Author:** ![valhalladsp](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/valhalladsp/32/71_2.png) [@valhalladsp](https://forum.juce.com/u/valhalladsp)\
**Post date:** [May 28, 2010, 6:10pm UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/7 "2010-05-28T18:10:09Z")

</div>

I just revisited this code, but it looks like getComponentUnderMouse() is no longer a member of Component. Is this correct?

Sean

---

<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 28, 2010, 7:18pm UTC](https://forum.juce.com/t/problems-with-custom-tooltip-method-combobox/5007/8 "2010-05-28T19:18:18Z")

</div>

> [@valhallasound](#):
>
> I just revisited this code, but it looks like getComponentUnderMouse() is no longer a member of Component. Is this correct?

That’s right. Now that there may be multiple simultaneous finger-touches, it doesn’t make any sense to assume there can only be one comp under the mouse. Use MouseInputSource::getComponentUnderMouse instead.
