Rework tooltip method in BView again.

Passing NULL or a blank string to SetToolTip(const char*) sets the
tooltip to NULL by calling SetToolTip(BToolTip*) with a NULL argument.

Calling SetToolTip(BToolTip*) with a NULL argument calls HideToolTip()
because sometimes the tool tip can change without the mouse moving,
for example because the user clicked.

Thanks Axeld and Stippi.
This commit is contained in:
John Scipione
2012-05-04 19:55:24 -04:00
parent 1a17461323
commit c645f9bcbe
+9 -7
View File
@@ -4817,6 +4817,11 @@ BView::DoLayout()
void
BView::SetToolTip(const char* text)
{
if (text == NULL || text[0] == '\0') {
SetToolTip((BToolTip*)NULL);
return;
}
if (BTextToolTip* tip = dynamic_cast<BTextToolTip*>(fToolTip))
tip->SetText(text);
else
@@ -4829,10 +4834,14 @@ BView::SetToolTip(BToolTip* tip)
{
if (fToolTip == tip)
return;
else if (tip == NULL)
HideToolTip();
if (fToolTip != NULL)
fToolTip->ReleaseReference();
fToolTip = tip;
if (fToolTip != NULL)
fToolTip->AcquireReference();
}
@@ -4851,13 +4860,6 @@ 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);