Change system cursor (like in CSS)?


#1

Is there a way to change the cursor over a renderer much like you can with CSS?

I am aware that you can replace the cursor with an image, but I prefer to have the “show cursor” option in the renderer on. Using the image method is much too laggy and just feels like I’m dragging the cursor through honey and the standard cursor works just fine since it is independent of the frame rate of the renderer (working with around 20-40 fps depending on the scene).

I would like to change the cursor to for example the horizontal arrows when hovering over a certain GUI element.

If a browser can change the system cursor it must be possible somehow. Does anybody know what it would take to do the same from vvvv?

Thanks.

ps: I think this might be how its done in Windows: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-change-the-cursor-type.


#2

dx9 or dx11?


#3

DX11


#4

@dottore didn’t you have such a node recently?


#5

Hey hey
This is the plugin that vux wrote at node on my machine.
Unfortunately we discovered that there’s a problem in vvvv that overwrite the settings chosen from the plugin as soon as you move the mouse again.
It would be nice if someone could have a look at it and fix it if possible.
this is such a stupid simple utility but so effective…

ValueControlCursor.zip (95.0 KB)


#6

ah, now i remember…i had a look and couldn’t find out why this plugin doesn’t work as one would expect. now i tried the same thing in a plain c# windows forms app (ie. no vvvv involved) and it behaves the same: when you move the cursor after setting it, it goes back to its default.

also did a quick search for the problem but didn’t find any clue…so i’m afraid i’m out of ideas here…


#7

Hm, yeah that is real strange. Its like something else is constantly resetting the cursor to its default. Very odd.

Oh well, no custom cursors then. But building a GUI in vvvv is an exercise in patience anyways. My dream would be to be able to just build the GUI in the browser like you would build a website and just send the controls over to vvvv bi-directionally. That way it would be rock solid, not slow down vvvv and with CSS and JS it would be a breeze to build even responsively. The pieces are probably already there…


#8

Maybe your dreams can come true here ? http://osc.ammd.net/


#9

@joreg
that’s what msdn says about Using Cursors

Your application can change the design of the cursor by using the SetCursor function and specifying a different cursor handle. However, when the cursor moves, the system redraws the class cursor at the new location. To prevent the class cursor from being redrawn, you must process the WM_SETCURSOR message. Each time the cursor moves and mouse input is not captured, the system sends this message to the window in which the cursor is moving.

so it could work by subclassing the windows and capturing the window message similar to the touch implementation


#10

here you go

how much is that worth to you?

SetCursorType.zip (4.9 KB)


#11

Thank you @woei, thats exactly what I need!

Since I want the switch the cursor only over certain elements, I have to use Ord2Enum and leave a second SetCursorType next to it for reference, but thats okay.

Is there a reason they are in that specific order? I would suggest maybe having No as the first option, Default second and then just doing them alphabetically. But thats just to make it a bit easier and with the simplest switching of Ord2Enum between 0 and 1 would just show the cursor or not. In the DX11 renderer the cursor display has to be set to enable first, which is off by default.

Anyways, this is the first important step to building proper GUIs in vvvv, so thank you very much!

ps: noticed a bug that I cant explain right now. After adding the Renderer(DX11) and pressing Alt+2 vvvv immediately crashes, but only in the help patch, otherwise it works as expected!?


#12

if you look into the code of the dynamic plugin you’ll see that the enum is generated directly from how .net enumerates the cursor types. this way enums will stay in sync with .net regardles if new ones are added or renamings are made.
one can overtake the visibility toggle of the dx11 renderer, but that renders the toggle it useless even after the plugin is deleted.

your second instance of the plugin shouldn’t be needed since all windows which are not specified by the window handle should keep their default cursor.

in case you need this plugin further refinded feel free to name a fee. otherwise the code is open for anyone to take over.


#13

@joreg there seems to be some kind of bug here. If you open the SetCursorType help file and place a DX11 renderer, then changing the window mode of that renderer crashes vvvv. I have tried a few things but can’t understand why it might happen. The help file was even created in the same version I am using (35.8). If I open a blank file it works fine, open the help file place a Renderer(DX11) or Preview(DX11) then press Alt+1,2 or 3 and I immediately get the “vvvv has stopped working” warning. Weird!?

@woei - its absolutely fine as it is and does what it should perfectly. If that’s the order .NET uses than its fine to stay like that. I think its great as it is and very useful for when you need it, especially since using the Cursor(DX11) node never satisfied me: It uses up to almost 800 ticks, instead of the 20 or so you use and only really works at high frame rates. Anything less than 30fps and the DX11 cursor becomes pretty useless because its not responsive enough. So I think your method should be the correct way to draw a cursor over a DX11 renderer. Could it be added to the addonpack?

compare_cursors_DX11.v4p (4.4 KB)


#14

@woei and @seltzdesign
here is the dynamic plugin adapted to work with beta36, System.Reactive is now one .dll that needs to be referenced differently and the input node base class signature has changed a little bit:

SetCursorType.zip (6.5 KB)


#15

also late coming to the game but DX11 renderer exposes its Control form object as a pin. So you can just directly set its cursor property so that it doesn’t require any sort of windows api pain. I’ve created a node doing that in mp.essentials.
setcursor

http://vvvvpm.github.io/#mp.essentials