Problems with custom tooltip method, ComboBox


#1

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


#2

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.


#3

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


#4

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


#5

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.


#6

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


#7

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

Sean


#8

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.