Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 10-30-2016, 09:45 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default ReaScript: Allow scripts to change mouse cursor [DONE! in extension API]

Aesthetic issues:
One of the complaints against using ReaScripts for MIDI editing is that the scripts do not look and feel as "elegant" as REAPER's native mouse modifier actions. (E.g. Reaper for Orchestral work and Display CC event through Curves instead of Bars.)

Practical issues:
It is not always obvious to the user that a deferred script is running (or which script is running), particularly if the script is not linked to a toolbar button. (E.g. CC stretching script.)

I suggest that both of these issues could be ameliorated if scripts could change the mouse cursor in REAPER's main UI, similar to how scripts can change the mouse cursor in its own GUI using gfx.setcursor.

Last edited by juliansader; 08-18-2018 at 07:27 AM.
juliansader is offline   Reply With Quote
Old 07-23-2017, 03:22 AM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Custom cursors can be faked by drawing a tooltip next to the cursor:

Code:
local xpos, ypos = reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip("♫", xpos+11, ypos+6, true)



Unfortunately, when using this hack in deferred MIDI scripts, the tooltip lags behind the cursor, due to the unnecessary sluggishness of the MIDI editor.
juliansader is offline   Reply With Quote
Old 07-23-2017, 02:05 PM   #3
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

Yes, big +1 to this request. We can periodically put a sort of banner popup at the top of the screen too, but having mouse cursor control would be sweet.
snooks is offline   Reply With Quote
Old 08-18-2018, 07:26 AM   #4
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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
Old 08-18-2018, 09:29 AM   #5
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

How cool is that! Will you add these to your MIDI CC scripts?
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-18-2018, 10:58 AM   #6
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by _Stevie_ View Post
How cool is that! Will you add these to your MIDI CC scripts?
Yep!

juliansader is offline   Reply With Quote
Old 08-18-2018, 11:10 AM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Sorry, where did these API functions come from? I don't see them listed anywhere.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-18-2018, 12:29 PM   #8
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

These are some of the API functions that I am adding the SWS, and the functions should be listed in the ReaScript API help webpage, together with all the other API functions.

My test build for Windows x64 can be download from the stash: https://stash.reaper.fm/34008/reaper_sws64.zip. (It was updated a few minutes ago.)
juliansader is offline   Reply With Quote
Old 08-18-2018, 12:35 PM   #9
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Ah, that's what I thought. It may be a good idea to avoid offering them as solutions until there's a new SWS pre available.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-18-2018, 12:51 PM   #10
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I'm actually hoping to pique others' curiosity so that they will test the new functions. The SWS release schedule is much too slow for us to wait.
juliansader is offline   Reply With Quote
Old 08-18-2018, 02:31 PM   #11
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

But the thread title says "solved" and there was no mention of your build until I asked. :P
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 08-21-2018, 01:30 PM   #12
D Rocks
Human being with feelings
 
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
Default

I like your work Juliansader and I'm currently using your new Zorder function for the Mixer visibility. Its almost perfectly solving the FX windows getting behind Mixer
__________________
Alex | www.drocksrecords.com | Thanks for REAPER
D Rocks is offline   Reply With Quote
Old 11-14-2019, 06:55 AM   #13
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,797
Default

Hi Julian! i'm very interested to change the cursor for custom actions but i couldn't make it with the code you provided because i have no experience and I don't know where to paste the code in order to work. Could you explain how can i do it please ?
Vagelis is offline   Reply With Quote
Old 11-14-2019, 08:03 AM   #14
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

The best place to ask is in the official thread for is Julian's extension:
https://forum.cockos.com/showthread.php?t=212174
__________________
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
Old 07-02-2020, 05:14 PM   #15
justcosmic1
Human being with feelings
 
Join Date: Dec 2013
Posts: 109
Default

Quote:
Originally Posted by juliansader View Post
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
I tried adding the reaper.Mouse_SetCursor(reaper.Mouse_LoadCursor(502 )) to an existing script but got a error message.
I then realised that I wanted to add it to some Reaper actions that couln't be edited (remove item I want an "eraser" type of icon).
It occrred to me that to ask if you could do a simple self contained script that could be used for custom actions?
For people like me who've not yet got into sripting - (though I'd love to), but who are very happy with custom and cycle actions, breaking out some of the API functionality such as the SetCursor, could be brilliant. It would then be just a matter of inserting either the correct number or correct patch depending.
I aks this as I suspect that if I try to just make a new script from the raw code that I will discover it isn't intended to be used that way...
Although I may try in the mean time anyway!
--
Just tried the above as Lua and getting "attempt to call a nil value(field"Mouse_LoadCursor")
(I do have the js_ReaScriptAPI installed)
Probably this is just way above my current level - hence the above request

Last edited by justcosmic1; 07-02-2020 at 05:37 PM.
justcosmic1 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 12:34 PM.


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