Skip to content

Commit dfce514

Browse files
committed
Fixed docs and added useHandCursor helper.
1 parent c74c1cb commit dfce514

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/input/InputManager.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,20 @@ var InputManager = new Class({
509509
*
510510
* If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use.
511511
*
512-
* Any valid CSS cursor value is allowed, including paths to image files. Please read about the differences
513-
* between browsers when it comes to the file formats and sizes supported:
512+
* Any valid CSS cursor value is allowed, including paths to image files, i.e.:
513+
*
514+
* ```javascript
515+
* this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer');
516+
* ```
517+
*
518+
* Please read about the differences between browsers when it comes to the file formats and sizes they support:
514519
*
515520
* https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
516521
* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property
517522
*
518523
* It's up to you to pick a suitable cursor format that works across the range of browsers you need to support.
519524
*
520-
* @method Phaser.Input.InputManager#setCursor
525+
* @method Phaser.Input.InputManager#setDefaultCursor
521526
* @since 3.10.0
522527
*
523528
* @param {string} cursor - The CSS to be used when setting the default cursor.

src/input/InputPlugin.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,7 @@ var InputPlugin = new Class({
13611361
* @property {function} [hitAreaCallback] - The callback that determines if the pointer is within the Hit Area shape or not.
13621362
* @property {boolean} [draggable=false] - If `true` the Interactive Object will be set to be draggable and emit drag events.
13631363
* @property {boolean} [dropZone=false] - If `true` the Interactive Object will be set to be a drop zone for draggable objects.
1364+
* @property {boolean} [useHandCursor=false] - If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`.
13641365
* @property {string} [cursor] - The CSS string to be used when the cursor is over this Interactive Object.
13651366
* @property {boolean} [pixelPerfect=false] - If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects.
13661367
* @property {integer} [alphaTolerance=1] - If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback.
@@ -1415,6 +1416,7 @@ var InputPlugin = new Class({
14151416
draggable = GetFastValue(config, 'draggable', false);
14161417
dropZone = GetFastValue(config, 'dropZone', false);
14171418
cursor = GetFastValue(config, 'cursor', false);
1419+
useHandCursor = GetFastValue(config, 'useHandCursor', false);
14181420
pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
14191421
alphaTolerance = GetFastValue(config, 'alphaTolerance', 1);
14201422

@@ -1443,7 +1445,7 @@ var InputPlugin = new Class({
14431445
var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input;
14441446

14451447
io.dropZone = dropZone;
1446-
io.cursor = cursor;
1448+
io.cursor = (useHandCursor) ? 'pointer' : cursor;
14471449

14481450
gameObject.input = io;
14491451

@@ -1964,15 +1966,20 @@ var InputPlugin = new Class({
19641966
*
19651967
* If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use.
19661968
*
1967-
* Any valid CSS cursor value is allowed, including paths to image files. Please read about the differences
1968-
* between browsers when it comes to the file formats and sizes supported:
1969+
* Any valid CSS cursor value is allowed, including paths to image files, i.e.:
1970+
*
1971+
* ```javascript
1972+
* this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer');
1973+
* ```
1974+
*
1975+
* Please read about the differences between browsers when it comes to the file formats and sizes they support:
19691976
*
19701977
* https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
19711978
* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property
19721979
*
19731980
* It's up to you to pick a suitable cursor format that works across the range of browsers you need to support.
19741981
*
1975-
* @method Phaser.Input.InputPlugin#setCursor
1982+
* @method Phaser.Input.InputPlugin#setDefaultCursor
19761983
* @since 3.10.0
19771984
*
19781985
* @param {string} cursor - The CSS to be used when setting the default cursor.

0 commit comments

Comments
 (0)