B4J Question ImageCursor's display size does not change on Windows

xulihang

Active Member
Licensed User
Longtime User
I am using the following code to set the image as a node's mouse cursor.

B4X:
Dim bc As BitmapCreator
bc.Initialize(SizeSlider.Value,SizeSlider.Value)
Dim r As B4XRect
r.Initialize(0,0,SizeSlider.Value,SizeSlider.Value)
bc.DrawRect(r,xui.Color_ARGB(120,255,0,0),True,1)
Dim img As Image = bc.Bitmap
Dim ImageCursor As JavaObject
ImageCursor.InitializeNewInstance("javafx.scene.ImageCursor",Array(img,img.Width/2,img.Height/2))
Dim jo As JavaObject = Canvas1
jo.RunMethod("setCursor", Array(ImageCursor))

On macOS, the cursor's size will change based on the bitmap's size. But on Windows, the display size is fixed. I wonder how to solve this problem.
 

kimstudio

Active Member
Licensed User
Longtime User
According to Javafx doc, seems Windows only supports cursor size 32 * 32, and Mac and Linux can have different size up to 64 * 64.

For alternatives I am thinking whether can set a blank/none cursor and self draw the image cursor for the size I want under mouse pointer.
 
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
According to Javafx doc, seems Windows only supports cursor size 32 * 32, and Mac and Linux can have different size up to 64 * 64.

For alternatives I am thinking whether can set a blank/none cursor and self draw the image cursor for the size I want under mouse pointer.
Thanks. Maybe I can set the cursor image to transparent and attatch an imageview to the cursor instead.
 
Upvote 0

Heuristx

Active Member
Licensed User
Longtime User
If I had to do something like this, I would look at Windows Accessibility first.
There are settings in Windows for people with vision problems. There may be some lower-level API to change the cursor size.
Dragging an imageview could be a huge pain unless you restrict it to a specific view/control.

 
Upvote 0
Top