Skip to content

Commit 0d2197d

Browse files
committed
Added new isOver property and method handlers.
1 parent 5b6920c commit 0d2197d

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

src/input/InputManager.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ var InputManager = new Class({
110110
*/
111111
this.domCallbacks = { up: [], down: [], move: [], upOnce: [], downOnce: [], moveOnce: [] };
112112

113+
/**
114+
* Are any mouse or touch pointers currently over the game canvas?
115+
* This is updated automatically by the canvas over and out handlers.
116+
*
117+
* @name Phaser.Input.InputManager#isOver
118+
* @type {boolean}
119+
* @readonly
120+
* @since 3.16.0
121+
*/
122+
this.isOver = true;
123+
124+
/**
125+
* isOver state change property.
126+
*
127+
* @name Phaser.Input.InputManager#_emitIsOverEvent
128+
* @type {boolean}
129+
* @private
130+
* @since 3.16.0
131+
*/
132+
this._emitIsOverEvent = false;
133+
113134
/**
114135
* Are there any up callbacks defined?
115136
*
@@ -418,6 +439,38 @@ var InputManager = new Class({
418439
*/
419440
},
420441

442+
/**
443+
* Internal canvas state change, called automatically by the Mouse Manager.
444+
*
445+
* @method Phaser.Input.InputManager#setCanvasOver
446+
* @private
447+
* @since 3.16.0
448+
*
449+
* @param {number} event - The DOM Event.
450+
*/
451+
setCanvasOver: function (event)
452+
{
453+
this.isOver = true;
454+
455+
this._emitIsOverEvent = event;
456+
},
457+
458+
/**
459+
* Internal canvas state change, called automatically by the Mouse Manager.
460+
*
461+
* @method Phaser.Input.InputManager#setCanvasOut
462+
* @private
463+
* @since 3.16.0
464+
*
465+
* @param {number} event - The DOM Event.
466+
*/
467+
setCanvasOut: function (event)
468+
{
469+
this.isOver = false;
470+
471+
this._emitIsOverEvent = event;
472+
},
473+
421474
/**
422475
* Internal update loop, called automatically by the Game Step.
423476
*
@@ -535,6 +588,9 @@ var InputManager = new Class({
535588
{
536589
this.canvas.style.cursor = this.defaultCursor;
537590
}
591+
592+
// Reset the isOver event
593+
this._emitIsOverEvent = null;
538594
},
539595

540596
/**

0 commit comments

Comments
 (0)