Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 10-19-2019, 08:39 AM   #1
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
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 10-19-2019, 08:51 AM   #2
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
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 10-19-2019, 09:07 AM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
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 10-19-2019, 10:46 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
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
Old 10-21-2019, 09:21 AM   #5
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yes, but it's only handy with one-liners, maybe twoliners. Everything beyond that makes displaying of the tooltip veeeerrryy sloowwww...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine 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 10:20 AM.


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