How to use Custom Cursor option in Module Designer
How to use Custom Cursor option in Module Designer
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).
-
- Posts: 49
- Joined: Sun Aug 25, 2019 10:26 am
Re: How to use Custom Cursor option in Module Designer
Not overly helpful, but I couldn't find any options to set custom cursors this evening. Hopefully CA can answer this.
-
- Posts: 74
- Joined: Mon Jan 28, 2019 5:51 am
Re: How to use Custom Cursor option in Module Designer
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.
-
- Posts: 49
- Joined: Sun Aug 25, 2019 10:26 am
Re: How to use Custom Cursor option in Module Designer
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.
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.
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);
}
Last edited by arbuxMusic on Thu Aug 13, 2020 11:45 pm, edited 1 time in total.
Re: How to use Custom Cursor option in Module Designer
I'm not the requester. Bat thank you for showing the way with good explanations.
Re: How to use Custom Cursor option in Module Designer
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!
-
- Posts: 49
- Joined: Sun Aug 25, 2019 10:26 am
Re: How to use Custom Cursor option in Module Designer
Thank you. I am glad it is helpful!