|
|
|
10-30-2016, 09:45 AM
|
#1
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.
|
|
|
07-23-2017, 03:22 AM
|
#2
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.
|
|
|
07-23-2017, 02:05 PM
|
#3
|
Banned
Join Date: Sep 2015
Posts: 1,650
|
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.
|
|
|
08-18-2018, 07:26 AM
|
#4
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.
|
|
|
08-18-2018, 09:29 AM
|
#5
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
How cool is that! Will you add these to your MIDI CC scripts?
|
|
|
08-18-2018, 10:58 AM
|
#6
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by _Stevie_
How cool is that! Will you add these to your MIDI CC scripts?
|
Yep!
|
|
|
08-18-2018, 11:10 AM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Sorry, where did these API functions come from? I don't see them listed anywhere.
|
|
|
08-18-2018, 12:29 PM
|
#8
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.)
|
|
|
08-18-2018, 12:35 PM
|
#9
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
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.
|
|
|
08-18-2018, 12:51 PM
|
#10
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
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.
|
|
|
08-18-2018, 02:31 PM
|
#11
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
But the thread title says "solved" and there was no mention of your build until I asked. :P
|
|
|
08-21-2018, 01:30 PM
|
#12
|
Human being with feelings
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
|
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
|
|
|
11-14-2019, 06:55 AM
|
#13
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,797
|
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 ?
|
|
|
07-02-2020, 05:14 PM
|
#15
|
Human being with feelings
Join Date: Dec 2013
Posts: 109
|
Quote:
Originally Posted by juliansader
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.
|
|
|
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:34 PM.
|