How to use Custom Cursor option in Module Designer

Post Reply
User avatar
AndyMac
Posts: 126
Joined: Wed Sep 05, 2018 6:16 pm
Location: Wirral UK
Contact:

How to use Custom Cursor option in Module Designer

Post by AndyMac » Thu Jul 16, 2020 1:09 pm

I want to use a custom cursor to indicate the availability of an area where right-clicking will bring up a pop-up (options) menu. There is nothing in the standard set of cursors (the hand being the closest, but not ideal, option) and I was wondering how to use the "custom" option that is listed as available in the enums for cursor types. I haven't found any details in the documentation or the javadocs (but may have simply missed it).
Andrew Macaulay

arbuxMusic
Posts: 48
Joined: Sun Aug 25, 2019 10:26 am

Re: How to use Custom Cursor option in Module Designer

Post by arbuxMusic » Wed Jul 22, 2020 12:42 pm

Not overly helpful, but I couldn't find any options to set custom cursors this evening. Hopefully CA can answer this.

flucatcher
Posts: 60
Joined: Mon Jan 28, 2019 5:51 am

Re: How to use Custom Cursor option in Module Designer

Post by flucatcher » Wed Jul 22, 2020 7:32 pm

Not a solution, but I have used flat buttons and a hover effect (with the option of changing skin when clicked), wont do anything with the cursor though.

arbuxMusic
Posts: 48
Joined: Sun Aug 25, 2019 10:26 am

Re: How to use Custom Cursor option in Module Designer

Post by arbuxMusic » Thu Aug 13, 2020 12:08 pm

Hi all,

I had a look at this issue again this evening.

The code I used to set a custom cursor is in the example is below. (I am using the most recent production release of Voltage Module Designer).

The custom cursor is a transparent PNG added to Extra Resources on a module. The image is applied as a cusom cursor using the SetCustomCursor function. SetMouseCursor(CustomCursor) is then used to display the newly set custom cursor. Call SetMouseCursor(Normal) to return the cursor back to the normal design.

Code: Select all

           // Add a png resource (with transparency) for your cursor to the Extra Resources for the module.
           // Your added resource is then referenced in the cursorResourceName parameter
           // For the cursor design, I recommend a contrasting outline so that the cursor is visible against all backgrounds.
           String cursorResourceName = "CustomCursor.png";
           
           // The cursor's hotspot is the center point for the cursor.
           // In this example, if you load the image, you can see that the center point
           // is at (15px, 15px) x/y.
           // If your cursor is a custom arrow pointing towards the upper left of the image, your hotspot would be 0, 0
           int hotSpotX = 15, hotSpotY = 15;
        
           // Setting a custom cursor is a two step operation:
           // - tell Voltage Modular which custom cursor to use
           // - tell Voltage Modular to show a custom cursor
           // NOTE: Watch for the incorrect enum name when dragging from the Library - it drags in as VoltageModule.MouseCursorTypes.CustomCustor. Note the mispelling in the final word - Custor -> Cursor
           MouseCursorTypes newCursor = VoltageModule.MouseCursorTypes.CustomCursor;
        
           // This method sets custom cursor image to the specified resource name and hotspot
           if (SetCustomCursor(cursorResourceName, hotSpotX, hotSpotY)) {
              // If the custom cursor was set OK, change to show a custom cursor
              // Note that this sets the cursor at the module level, so when the mouse leaves, we'll need to reset the cursor to the standard cursor type. See the Object_MouseLeave for the code to do this.
              SetMouseCursor(newCursor);
           }
           
I have posted a sample module that sets a cursor when hovering over a control at https://github.com/arbuxMusic/voltage-m ... tom-Cursor. The module/code is available in the CustomCursor folder on https://github.com/arbuxMusic/voltage-modular-examples.
Last edited by arbuxMusic on Thu Aug 13, 2020 11:45 pm, edited 1 time in total.

User avatar
seal58
Posts: 80
Joined: Fri Jul 12, 2019 5:28 pm

Re: How to use Custom Cursor option in Module Designer

Post by seal58 » Thu Aug 13, 2020 1:16 pm

I'm not the requester. Bat thank you for showing the way with good explanations. :P

User avatar
AndyMac
Posts: 126
Joined: Wed Sep 05, 2018 6:16 pm
Location: Wirral UK
Contact:

Re: How to use Custom Cursor option in Module Designer

Post by AndyMac » Thu Aug 13, 2020 1:21 pm

Thank you so much for this reply - and for a really clear explanation! Will look at using this in an upcoming release to make the UI even more discoverable.... and thanks for the resources you are making available on GitHub - this a really useful resource for us all. Kudos!
Andrew Macaulay

arbuxMusic
Posts: 48
Joined: Sun Aug 25, 2019 10:26 am

Re: How to use Custom Cursor option in Module Designer

Post by arbuxMusic » Thu Aug 13, 2020 11:48 pm

Thank you. I am glad it is helpful!

Post Reply