|
|
|
04-01-2023, 09:09 AM
|
#1
|
Human being with feelings
Join Date: Dec 2021
Posts: 7
|
Way to check if mouse is hovering over media item bottom half?
I'm working on this script that will automatically set the play cursor to the start of an item whenever I drag it:
Code:
local function move_playhead_to_start_of_selected_item()
reaper.Main_OnCommandEx(41173, 0, 0) -- go to start of selected item
end
local function media_item_left_drag()
-- wait until the left mouse button is released
while reaper.JS_Mouse_GetState(1) == true do
reaper.sleep(0.05)
end
-- check if left drag was performed on a media item
local _, _, _ = reaper.BR_ItemAtMouseCursor()
if _ ~= -1 then
-- move playhead to start of selected item
move_playhead_to_start_of_selected_item()
end
end
local function defer()
media_item_left_drag()
reaper.defer(defer)
end
-- run the script in the background
reaper.atexit(function() end) -- disable atexit function
defer() -- start main function
I'd like to replace reaper.BR_ItemAtMouseCursor() with something that will check for media item bottom half specifically so that I can still edit the item normally in the top half. What would be the best way to set this up?
|
|
|
04-01-2023, 10:03 AM
|
#2
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Maybe this give you some ideas,
Code:
-- Show tooltip when mouse over bottom of item
-- Tested: Win10, REAPER v6.75+dev0216, js_ReaScriptAPI v1.31
-- * Supports items in Fixed Lanes (REAPER v6.75+dev0216)
local arrange_hwnd = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
function Loop()
local x,y = reaper.GetMousePosition()
local item = reaper.GetItemFromPoint(x, y, true)
if item then
local track = reaper.GetTrackFromPoint(x, y)
local tr_y = reaper.GetMediaTrackInfo_Value(track, "I_TCPY")
local item_y = reaper.GetMediaItemInfo_Value(item, "I_LASTY")
local item_h = reaper.GetMediaItemInfo_Value(item, "I_LASTH")
local item_center = tr_y + item_y + (item_h / 2)
local cx, cy = reaper.JS_Window_ScreenToClient(arrange_hwnd, x, y)
if cy >= item_center then
reaper.TrackCtl_SetToolTip("Item Bottom", x-32, y-32, true)
else
reaper.TrackCtl_SetToolTip("", 0, 0, false)
end
end
reaper.defer(Loop)
end
|
|
|
04-01-2023, 10:38 AM
|
#4
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by vitalker
|
Those don't work correctly if item(s) are in a Fixed Lane (+dev builds).
|
|
|
04-01-2023, 10:59 AM
|
#5
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by Edgemeal
Those don't work correctly if item(s) are in a Fixed Lane (+dev builds).
|
There is a cursor for bottom half in dev builds or they've deleted it?
|
|
|
04-01-2023, 11:13 AM
|
#6
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by vitalker
There is a cursor for bottom half in dev builds or they've deleted it?
|
No, they removed that some time ago.
|
|
|
04-01-2023, 01:41 PM
|
#7
|
Human being with feelings
Join Date: Dec 2021
Posts: 7
|
Alright here's where I landed with it. I set it up to trigger on both drag and also left click so it could replace a custom action I had made for that. Appreciate the help y'all!
Last edited by glaiwo; 04-01-2023 at 01:47 PM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 12:27 PM.
|