Skip to content

Commit 1b28080

Browse files
committed
Added pointerupoutside and pointerdownoutside events.
1 parent 5b5b83d commit 1b28080

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/input/InputPlugin.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ var InputPlugin = new Class({
758758
* @fires Phaser.GameObjects.GameObject#pointerdownEvent
759759
* @fires Phaser.Input.InputPlugin#gameobjectdownEvent
760760
* @fires Phaser.Input.InputPlugin#pointerdownEvent
761+
* @fires Phaser.Input.InputPlugin#pointerdownoutsideEvent
761762
* @since 3.0.0
762763
*
763764
* @param {Phaser.Input.Pointer} pointer - The Pointer being tested.
@@ -805,10 +806,13 @@ var InputPlugin = new Class({
805806
}
806807
}
807808

808-
// Contains ALL Game Objects currently over in the array
809+
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
809810
if (!aborted)
810811
{
811-
this.emit('pointerdown', pointer, currentlyOver);
812+
var type = (pointer.downElement === this.manager.game.canvas) ? 'pointerdown' : 'pointerdownoutside';
813+
814+
// Contains ALL Game Objects currently up in the array
815+
this.emit(type, pointer, currentlyOver);
812816
}
813817

814818
return total;
@@ -1344,6 +1348,7 @@ var InputPlugin = new Class({
13441348
* @private
13451349
* @fires Phaser.GameObjects.GameObject#pointerupEvent
13461350
* @fires Phaser.Input.InputPlugin#gameobjectupEvent
1351+
* @fires Phaser.Input.InputPlugin#gameobjectupoutsideEvent
13471352
* @since 3.0.0
13481353
*
13491354
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
@@ -1371,8 +1376,6 @@ var InputPlugin = new Class({
13711376
continue;
13721377
}
13731378

1374-
// pointerupoutside
1375-
13761379
gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
13771380

13781381
if (_eventData.cancelled)
@@ -1390,10 +1393,13 @@ var InputPlugin = new Class({
13901393
}
13911394
}
13921395

1396+
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
13931397
if (!aborted)
13941398
{
1399+
var type = (pointer.upElement === this.manager.game.canvas) ? 'pointerup' : 'pointerupoutside';
1400+
13951401
// Contains ALL Game Objects currently up in the array
1396-
this.emit('pointerup', pointer, currentlyOver);
1402+
this.emit(type, pointer, currentlyOver);
13971403
}
13981404

13991405
return currentlyOver.length;
@@ -2699,4 +2705,14 @@ module.exports = InputPlugin;
26992705
* @event Phaser.Input.InputPlugin#pointerupEvent
27002706
* @param {Phaser.Input.Pointer} pointer - The Pointer.
27012707
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer.
2708+
*
2709+
* A Pointer was pressed down outside of the game canvas.
2710+
* @event Phaser.Input.InputPlugin#pointerdownoutsideEvent
2711+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2712+
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer.
2713+
*
2714+
* A Pointer was released outside of the game canvas.
2715+
* @event Phaser.Input.InputPlugin#pointerupoutsideEvent
2716+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2717+
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer.
27022718
*/

0 commit comments

Comments
 (0)