Page 1 of 1

How to use Custom Cursor option in Module Designer

Posted: Thu Jul 16, 2020 1:09 pm
by AndyMac
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).

Re: How to use Custom Cursor option in Module Designer

Posted: Wed Jul 22, 2020 12:42 pm
by arbuxMusic
Not overly helpful, but I couldn't find any options to set custom cursors this evening. Hopefully CA can answer this.

Re: How to use Custom Cursor option in Module Designer

Posted: Wed Jul 22, 2020 7:32 pm
by flucatcher
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.

Re: How to use Custom Cursor option in Module Designer

Posted: Thu Aug 13, 2020 12:08 pm
by arbuxMusic
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.

Re: How to use Custom Cursor option in Module Designer

Posted: Thu Aug 13, 2020 1:16 pm
by seal58
I'm not the requester. Bat thank you for showing the way with good explanations. :P

Re: How to use Custom Cursor option in Module Designer

Posted: Thu Aug 13, 2020 1:21 pm
by AndyMac
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!

Re: How to use Custom Cursor option in Module Designer

Posted: Thu Aug 13, 2020 11:48 pm
by arbuxMusic
Thank you. I am glad it is helpful!