View Single Post
Old 08-04-2019, 04:34 PM   #26
nappies
Human being with feelings
 
nappies's Avatar
 
Join Date: Dec 2017
Posts: 302
Default

Quote:
Originally Posted by nofish View Post
@Justin
If tracks no longer have windows how do we detect 'mouse over TCP' now?
TrackFromPoint() works over TCP too but we'd need to know TCP width to be able to differentiate between TCP and track lane I guess?
Here how we get tcp panel to combine this two functions. GetTrackFromPoint get only only tcp panel. JS_API required.

Code:
function  get_tcp_win()
local hwnd= reaper.JS_Window_FindChildByID( reaper.GetMainHwnd(), 1259)
 tcp_win = reaper.JS_Window_GetRelated(reaper.JS_Window_GetRelated(hwnd, "NEXT"), "NEXT")
return tcp_win
end


function GetTrackFromPoint(x, y)

if reaper.JS_Window_FromPoint( x, y )==get_tcp_win() then

local _, left, tcptop, right, _ = reaper.JS_Window_GetClientRect(get_tcp_win())

local count_tr=reaper.CountTracks(0) 
if count_tr==0 then return end 
for i=1, count_tr do  
local tr=reaper.GetTrack( 0, i-1)
local tr_h = reaper.GetMediaTrackInfo_Value( tr, "I_TCPH" )
local tr_y = reaper.GetMediaTrackInfo_Value( tr, "I_TCPY" )
local top = (tcptop+tr_y) 
local bottom  = (top+tr_h) 
if x> left and x<right and y>top and y<bottom then track=tr break end 
 
end 
end
return track
end
nappies is offline   Reply With Quote