Old Yesterday, 08:39 AM   #1
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 191
Default What is the correct way to close a tooltip made by TrackCtl_SetToolTip?

I think the tooltip stay too long before disappear. I tried this today:
Code:
x,y=reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip("hello", x, y, false)
h=reaper.GetTooltipWindow()
time=os.time()

function countdown()
  local check=os.time()
  if check-time>=2 then  --close the tooltip after 2 seconds
    reaper.JS_Window_Destroy(h)
  else
      reaper.defer(countdown)
  end
end
countdown()
Actually it worked. But if I run this script again, the tooltip never show, until I restarted REAPER. It looks like it was literally destroied. So is there a correct way to close it?
dsyrock is offline   Reply With Quote
Old Yesterday, 08:51 AM   #2
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 191
Default

This seems to work

Code:
x,y=reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip("hello", x, y, false)
h=reaper.GetTooltipWindow()
time=os.time()

function countdown()
  local check=os.time()
  if check-time>=2 then  --close the tooltip after 2 seconds
    reaper.TrackCtl_SetToolTip("", x, y, false)
  else
      reaper.defer(countdown)
  end
end
countdown()
Maybe give it an empty content can somehow close it.
dsyrock is offline   Reply With Quote
Old Yesterday, 09:07 AM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,052
Default

Quote:
Originally Posted by dsyrock View Post
Maybe give it an empty content can somehow close it.
That's what's written in the API doc. :P

Quote:
displays tooltip at location, or removes if empty string
nofish is offline   Reply With Quote
Old Yesterday, 10:46 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,036
Default

Actually this function is totally underused but I think it has great potential


I found a way to only display message for few seconds,
it is very handy as "error message" for scripts, like "no items selected" rather than using popups or displaying console message.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.