[haiku-commits] haiku: hrev44105 - src/kits/interface
- From: jscipione@xxxxxxxxx
- To: haiku-commits@xxxxxxxxxxxxx
- Date: Sat, 5 May 2012 01:59:48 +0200 (CEST)
hrev44105 adds 1 changeset to branch 'master'
old head: 1a17461323bf10ed380aadd63dadee2b304cb7c6
new head: c645f9bcbeab32cfb3c631a1340d38ebf5fd2d6f
----------------------------------------------------------------------------
c645f9b: 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.
[ John Scipione <jscipione@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev44105
Commit: c645f9bcbeab32cfb3c631a1340d38ebf5fd2d6f
URL: http://cgit.haiku-os.org/haiku/commit/?id=c645f9b
Author: John Scipione <jscipione@xxxxxxxxx>
Date: Fri May 4 23:49:41 2012 UTC
----------------------------------------------------------------------------
1 file changed, 9 insertions(+), 7 deletions(-)
src/kits/interface/View.cpp | 16 +++++++++-------
----------------------------------------------------------------------------
diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index 80ec21d..5078f2f 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -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);
Other related posts: