Overview
A custom image representation of the mouse cursor. On platforms that don't
support custom cursors, Cursor.DEFAULT
will be used in place of the
specified ImageCursor.
Example:
import javafx.scene.*; import javafx.scene.image.*; def image = Image { url: "{__DIR__}mycursor.png" } Scene { width: 400 height: 300 cursor: ImageCursor { image: image hotspotX: image.width/2 hotspotY: image.height/2 } }
Profile: common
Variable Summary
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public-init | hotspotX | Number | 0 |
The X coordinate of the cursor's hot spot. The X coordinate of the cursor's hot spot. This hotspot represents the location within the cursor image that will be displayed at the mouse position. This must be in the range of [0,image.width-1]. A value less than 0 will be set to 0. A value greater than image.width-1 will be set to image.width-1. 0 |
|||
public-init | hotspotY | Number | 0 |
The Y coordinate of the cursor's hot spot. The Y coordinate of the cursor's hot spot. This hotspot represents the location within the cursor image that will be displayed at the mouse position. This must be in the range of [0,image.height-1]. A value less than 0 will be set to 0. A value greater than image.height-1 will be set to image.height-1. 0 |
|||
public-init | image | Image | null |
The image to display when the cursor is active. The image to display when the cursor is active. If the image is null,
|
Inherited Variables
Script Function Summary
- public chooseBestCursor(images: Image[], hotspotX: Number, hotspotY: Number) : ImageCursor
-
Creates a custom image cursor from one of the specified images.
Creates a custom image cursor from one of the specified images. This function will choose the image whose size most closely matched the best cursor size. The hotpotX of the returned ImageCursor is scaled by chosenImage.width/images[0].width and the hotspotY is scaled by chosenImage.height/images[0].height.
On platforms that don't support custom cursors,
Cursor.DEFAULT
will be used in place of the returned ImageCursor.-
Parameters
- images
- a sequence of images from which to choose, in order of preference
- hotspotX
- the X coordinate of the hotspot within the first image in the images sequence
- hotspotY
- the Y coordinate of the hotspot within the first image in the images sequence
-
Returns
- ImageCursor
- a cursor created from the best image
Profile: common
- public getBestSize(preferredWidth: Number, preferredHeight: Number) : Dimension2D
-
Gets the supported cursor size that is closest to the specified preferred size.
Gets the supported cursor size that is closest to the specified preferred size. A value of (0,0) is returned if the platform does not support custom cursors.
Note: if an image is used whose dimensions don't match a supported size (as returned by this method), the implementation will resize the image to a supported size. This may result in a loss of quality.
Note: These values can vary between operating systems, graphics cards and screen resolution, but at the time of this writing, a sample Windows Vista machine returned 32x32 for all requested sizes, while sample Mac and Linux machines returned the requested size up to a maximum of 64x64. Applications should provide a 32x32 cursor, which will work well on all platforms, and may optionally wish to provide a 64x64 cursor for those platforms on which it is supported.
-
Parameters
- preferredWidth
- the preferred width of the cursor
- preferredHeight
- the preferred height of the cursor
-
Returns
- Dimension2D
- the supported cursor size
Profile: common
- public getMaximumColors() : Integer
-
Returns the maximum number of colors supported in a custom image cursor palette.
Returns the maximum number of colors supported in a custom image cursor palette.
Note: if an image is used which has more colors in its palette than the supported maximum, the implementation will attempt to flatten the palette to the maximum. This may result in a loss of quality.
Note: These values can vary between operating systems, graphics cards and screen resolution, but at the time of this writing, a sample Windows Vista machine returned 256, a sample Mac machine returned Integer.MAX_VALUE, indicating support for full color cursors, and a sample Linux machine returned 2. Applications may want to target these three color depths for an optimal cursor on each platform.
-
Returns
- Integer
- the maximum number of colors supported in a custom image cursor palette
Profile: common