Fix another tooltip related bug that appears in Deskbar.

The bug is that in horizontal mode the tooltip will remain set to
the last moused over team menu item even if the mouse is no longer
over a menu item. The bug can be seen in the following screenshot:

http://26.media.tumblr.com/tumblr_m3gze8s1xi1r0f0hfo1_400.png

To fix this bug, allow you to set the tooltip text to blank or NULL
in SetToolTip(const char* text). In ShowToolTip() check to see if
the tooltip text is blank or NULL and if so, don't show the tip.
Setting the tooltip to blank or NULL effectively unsets the tooltip
on a view.
This commit is contained in:
John Scipione
2012-05-03 20:49:18 -04:00
parent 91bc463512
commit 5ccf455f7e
2 changed files with 22 additions and 21 deletions
+15 -18
View File
@@ -400,24 +400,26 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
case B_INSIDE_VIEW:
{
TTeamMenuItem* item = TeamItemAtPoint(where);
if (item == NULL) {
// item is NULL, break out
fLastMousedOverItem = NULL;
break;
}
if (item->HasLabel()) {
// item has a visible label, set the item and break out
fLastMousedOverItem = item;
break;
}
if (item == fLastMousedOverItem) {
// already set the tooltip for this item, break out
break;
}
// new item, update the tooltip with the item name
if (item == NULL) {
// item is NULL, remove the tooltip and break out
fLastMousedOverItem = NULL;
SetToolTip((const char*)NULL);
break;
}
if (item->HasLabel()) {
// item has a visible label, remove the tooltip and break out
fLastMousedOverItem = item;
SetToolTip((const char*)NULL);
break;
}
// new item, set the tooltip to the item name
SetToolTip(item->Name());
// save the current item for the next MouseMoved() call
@@ -425,11 +427,6 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
break;
}
case B_OUTSIDE_VIEW:
case B_EXITED_VIEW:
fLastMousedOverItem = NULL;
break;
}
BMenuBar::MouseMoved(where, code, message);
+7 -3
View File
@@ -4817,9 +4817,6 @@ BView::DoLayout()
void
BView::SetToolTip(const char* text)
{
if (text == NULL || text[0] == '\0')
return;
if (BTextToolTip* tip = dynamic_cast<BTextToolTip*>(fToolTip))
tip->SetText(text);
else
@@ -4854,6 +4851,13 @@ BView::ShowToolTip(BToolTip* tip)
if (tip == NULL)
return;
if (BTextToolTip* textTip = dynamic_cast<BTextToolTip*>(tip)) {
const char* text = textTip->Text();
// if text is NULL or blank don't show the tooltip
if (text == NULL || text[0] == '\0')
return;
}
BPoint where;
GetMouse(&where, NULL, false);