From 4593a42a5bf86d50e67c60978101edc998fbb2aa Mon Sep 17 00:00:00 2001 From: KLV Date: Sun, 3 Nov 2013 23:43:47 +0100 Subject: [PATCH] Mouse property to say what button is being clicked It follows the convention that already was in the file 0 for left, 1 for middle and 2 for right. It also changes to -1 when mouseUp. --- src/input/Mouse.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/input/Mouse.js b/src/input/Mouse.js index 3a781c01..6abbd983 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -41,6 +41,11 @@ Phaser.Mouse = function (game) { * @default */ this.mouseUpCallback = null; + /** + * @property {Description} mouseTypeDown - The type of click. -1 for not clicking + * @default + */ + this.mouseTypeDown = -1; /** * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. @@ -119,6 +124,8 @@ Phaser.Mouse.prototype = { event.preventDefault(); + this.mouseTypeDown = event.which - 1; + if (this.mouseDownCallback) { this.mouseDownCallback.call(this.callbackContext, event); @@ -169,6 +176,8 @@ Phaser.Mouse.prototype = { event.preventDefault(); + this.mouseTypeDown = -1; + if (this.mouseUpCallback) { this.mouseUpCallback.call(this.callbackContext, event); @@ -262,4 +271,4 @@ Phaser.Mouse.prototype = { } -}; \ No newline at end of file +};