View Single Post
Old 08-18-2018, 07:26 AM   #4
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,004
Default

Using some new API functions, the mouse cursor can be changed:
Code:
reaper.Mouse_SetCursor(reaper.Mouse_LoadCursor(191)) -- Loads REAPER's native "key signature" cursor
Code:
reaper.Mouse_SetCursor(reaper.Mouse_LoadCursorFromFile("...file path and name...")) -- Loads custom cursor

When the script terminates, or after each defer cycle, REAPER will change the new cursor back. To prevent this -- as long as the mouse stays within a certain window -- one can use:
Code:
reaper.WindowMessage_Intercept(window, "WM_SETCURSOR:block")

To restore the cursor if it has moved out of the window, try this:
Code:
function loop()
    if reaper.Window_FromPoint(reaper.GetMousePosition()) ~= window then
        wasOutsideWindow = true
    elseif wasOutsideWindow then
        wasOutsideWindow = false
        reaper.Mouse_SetCursor(reaper.Mouse_LoadCursor(502)) -- Set cursor again
        -- Since WM_SETCURSOR is being blocked, we must tell the window to update cursor
        reaper.WindowMessage_Send(window, "WM_SETCURSOR", 0, 0, 0, 0)
    end
    reaper.defer(loop)
end

function exit()
    reaper.WindowMessage_ReleaseWindow(window)
end

Last edited by juliansader; 08-18-2018 at 12:26 PM.
juliansader is offline   Reply With Quote