From 5ccf455f7ee43be8060cd4b45c563e0a30ffaf50 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 3 May 2012 20:41:52 -0400 Subject: [PATCH] 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. --- src/apps/deskbar/ExpandoMenuBar.cpp | 33 +++++++++++++---------------- src/kits/interface/View.cpp | 10 ++++++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 390c4e69eb..2dfe039447 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -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); diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 4d34a389be..80ec21d191 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -4817,9 +4817,6 @@ BView::DoLayout() void BView::SetToolTip(const char* text) { - if (text == NULL || text[0] == '\0') - return; - if (BTextToolTip* tip = dynamic_cast(fToolTip)) tip->SetText(text); else @@ -4854,6 +4851,13 @@ BView::ShowToolTip(BToolTip* tip) if (tip == NULL) return; + if (BTextToolTip* textTip = dynamic_cast(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);