Old 09-02-2019, 04:11 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default Where can I find info on how to assign an icon to the mouse?

Hey gang,

Any tutorials or links on how to assign a the mouse a different tool icon when running different scripts? I'm coming up empty.

Thanks.

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB

Last edited by Thonex; 09-02-2019 at 04:21 PM.
Thonex is online now   Reply With Quote
Old 09-02-2019, 05:33 PM   #2
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 1,866
Default

you may wanna look here: https://www.reaper.fm/sdk/cursors/cursors.php

.
__________________
[Check out my free VST plugin collection here.]
SonicAxiom is offline   Reply With Quote
Old 09-02-2019, 06:42 PM   #3
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Quote:
Originally Posted by SonicAxiom View Post
Thanks Sonic!

Yeah... that was one of the first hits I got. But it doesn't' really say how to attach an action to a script... or give the syntax for doing so -- unless I'm blind... which I certainly can be.

I did find this:

https://www.extremraym.com/cloud/rea...CursorFromFile

But I must be missing something fairly obvious. I just don't know what :O

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   Reply With Quote
Old 09-02-2019, 06:57 PM   #4
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 1,866
Default

sorry, no clue

paging X-Raym ...

.
__________________
[Check out my free VST plugin collection here.]
SonicAxiom is offline   Reply With Quote
Old 09-02-2019, 11:57 PM   #5
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,713
Default

Hi Andrew,

here's a short .lua example you can try: -- EDIT: This example works only on Windows (see post #7)
Code:
local function changeToCustomCursor()
  local path = "../Cursors/CustomIcon.cur"
  local cursorHandle = reaper.JS_Mouse_LoadCursorFromFile(path)
  reaper.JS_Mouse_SetCursor(cursorHandle)

  reaper.defer(changeToCustomCursor) -- update cursor after moving the mouse
end

reaper.defer(changeToCustomCursor) -- call the function the first time
I guess in order to 'assign' a cursor to a specific Script/Action, you'll basically have to change the cursor icon before running the Script/Action ...
As example:
  • 1) Change cursor to icon 1
  • 2) Run script 1
  • 1) Change cursor to icon 2
  • 2) Run script 2
And so on ...


... and/or keep the cursor icon updated while running the Script/Action:
Quote:
void JS_Mouse_SetCursor(void* cursorHandle): Sets the mouse cursor. (Only lasts while script is running, and for a single "defer" cycle.)
__________________
ReaLauncher

Last edited by solger; 09-03-2019 at 11:39 AM.
solger is offline   Reply With Quote
Old 09-03-2019, 09:13 AM   #6
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Thanks Solger,

I'll try to see if I can pull this off.

Regarding paths... do you happen to know if relative paths are ok?

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   Reply With Quote
Old 09-03-2019, 10:32 AM   #7
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,713
Default

Quote:
Originally Posted by Thonex View Post
Regarding paths... do you happen to know if relative paths are ok?
Well, the path in my example is already a relative one, so I guess it's OK. Using local path = "Cursors/CustomIcon.cur" seems to work also.
But I only tested it on Windows, so far (and not on macOS or Linux).

EDIT: I just did a quick test on macOS and using the example code from post #5 doesn't seem to work there. So here's an adapted version:
Code:
local function changeToCustomCursor()
  -- get the 'Cursors' subdirectory in the Reaper resource folder
  local resourcePath = reaper.GetResourcePath() .. "/Cursors/"
  local cursorHandle = reaper.JS_Mouse_LoadCursorFromFile(resourcePath .. "CustomIcon.cur")
  reaper.JS_Mouse_SetCursor(cursorHandle)

  reaper.defer(changeToCustomCursor)
end

reaper.defer(changeToCustomCursor)
__________________
ReaLauncher

Last edited by solger; 09-03-2019 at 11:06 AM.
solger is offline   Reply With Quote
Old 09-03-2019, 11:12 AM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Quote:
Originally Posted by solger View Post
Well, the path in my example is already a relative one, so I guess it's OK. Using local path = "Cursors/CustomIcon.cur" seems to work also.
But I only tested it on Windows, so far (and not on macOS or Linux).

EDIT: I just did a quick test on macOS and using the example code from post #5 doesn't seem to work there. So here's an adapted version:
Code:
local function changeToCustomCursor()
  -- get the 'Cursors' subdirectory in the Reaper resource folder
  local resourcePath = reaper.GetResourcePath() .. "/Cursors/"
  local cursorHandle = reaper.JS_Mouse_LoadCursorFromFile(resourcePath .. "CustomIcon.cur")
  reaper.JS_Mouse_SetCursor(cursorHandle)

  reaper.defer(changeToCustomCursor)
end

reaper.defer(changeToCustomCursor)
Thanks so much Solger. Really appreciate your help.

Will give that a try. I'm noticing I'm having mouse anomalies with Reaper in general. Using Julian Sader's awesome MIDI scripts... I'm getting no custom mouse icon when I know there is one:

https://forum.cockos.com/showpost.ph...&postcount=686

So I'll have to dig deeper and hopefully I can get this to work.

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   Reply With Quote
Old 09-03-2019, 11:16 AM   #9
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Your script DID work. I'm on Mac

Thanks so much... now to see if I can d something useful with it!!

I wonder if that script also works with Windows. Would be nice to know there is a unified script solution.

I'm sure it does.

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   Reply With Quote
Old 09-03-2019, 11:22 AM   #10
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,713
Default

Quote:
Originally Posted by Thonex View Post
I wonder if that script also works with Windows. Would be nice to know there is a unified script solution.
Yes, I did a quick test with the updated version from post #7 on both macOS and Windows
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 09-03-2019, 11:42 AM   #11
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Quote:
Originally Posted by solger View Post
Yes, I did a quick test with the updated version from post #7 on both macOS and Windows
Fantastic!!! Thanks again solger!
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   Reply With Quote
Old 09-05-2019, 02:40 PM   #12
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,699
Default

Another trick to prevent REAPER from changing your custom mouse cursor in-between every defer cycle, causing the cursor to flicker, is to block the WM_SETCURSOR window message while the script is running. This will work while the mouse is over the window of interest:
Code:
reaper.JS_WindowMessage_Intercept(windowOfInterest, "WM_SETCURSOR", false)
If the mouse moves out of the window, you can change the cursor back again with SetCursor.

This is how I load a mouse cursor when the script starts:
Code:
    -- MOUSE CURSOR AND TOOLBAR BUTTON:
    -- (Later, the script will block "WM_SETCURSOR" to prevent REAPER from changing the cursor back after each defer cycle.)
    _, filename, sectionID, commandID = reaper.get_action_context()
    filename = filename:gsub("\\", "/") -- Change Windows format to cross-platform
    filename = filename:match("^.*/") -- Remove script filename, keeping directory
    filename = filename .. "js_Mouse editing - Arch and Tilt.cur"
    cursor = reaper.JS_Mouse_LoadCursorFromFile(filename) -- The first time that the cursor is loaded in the session will be slow, but afterwards the extension will re-use previously loaded cursor
    if not cursor then cursor = reaper.JS_Mouse_LoadCursor(527) end -- If .cur file unavailable, load one of REAPER's own cursors]]
    if cursor then reaper.JS_Mouse_SetCursor(cursor) end
To find the numbers of REAPER's built-in cursors (as used in the last lines of the example), check out the discussion in WDL/SWELL and C++ extensions: How to change mouse cursor?. (BTW, it turned out that not all of REAPER's embedded cursors are available on macOS, so Arch and Tilt has to load its cursor from a file when on macOS.)

Last edited by juliansader; 09-05-2019 at 02:55 PM.
juliansader is offline   Reply With Quote
Old 09-06-2019, 02:49 PM   #13
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 684
Default

Quote:
Originally Posted by juliansader View Post
Another trick to prevent REAPER from changing your custom mouse cursor in-between every defer cycle, causing the cursor to flicker, is to block the WM_SETCURSOR window message while the script is running. This will work while the mouse is over the window of interest:
Code:
reaper.JS_WindowMessage_Intercept(windowOfInterest, "WM_SETCURSOR", false)
If the mouse moves out of the window, you can change the cursor back again with SetCursor.

This is how I load a mouse cursor when the script starts:
Code:
    -- MOUSE CURSOR AND TOOLBAR BUTTON:
    -- (Later, the script will block "WM_SETCURSOR" to prevent REAPER from changing the cursor back after each defer cycle.)
    _, filename, sectionID, commandID = reaper.get_action_context()
    filename = filename:gsub("\\", "/") -- Change Windows format to cross-platform
    filename = filename:match("^.*/") -- Remove script filename, keeping directory
    filename = filename .. "js_Mouse editing - Arch and Tilt.cur"
    cursor = reaper.JS_Mouse_LoadCursorFromFile(filename) -- The first time that the cursor is loaded in the session will be slow, but afterwards the extension will re-use previously loaded cursor
    if not cursor then cursor = reaper.JS_Mouse_LoadCursor(527) end -- If .cur file unavailable, load one of REAPER's own cursors]]
    if cursor then reaper.JS_Mouse_SetCursor(cursor) end
To find the numbers of REAPER's built-in cursors (as used in the last lines of the example), check out the discussion in WDL/SWELL and C++ extensions: How to change mouse cursor?. (BTW, it turned out that not all of REAPER's embedded cursors are available on macOS, so Arch and Tilt has to load its cursor from a file when on macOS.)
Thanks so much Julian!!

This will be great. These are the kinds of things I was looking for. Little tricks to get things to work. I could tell by looking around the Internet that’s that this was not going to be a simple ordeal. Of course everything is easy when you know how… But when you don’t… It can be very confusing.

Thanks for pointing this out… I’m sure it will be invaluable
__________________
Cheers,
Andrew K
v5.982/64 Mac 10.12.+, i7 Quad 2.9GHz, 24GB
Thonex is online now   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 05:29 PM.


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