From 4593a42a5bf86d50e67c60978101edc998fbb2aa Mon Sep 17 00:00:00 2001 From: KLV Date: Sun, 3 Nov 2013 23:43:47 +0100 Subject: [PATCH 1/3] 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 +}; From e8bac6c8c7b8f40fc95279f7997fbb60e5cf4815 Mon Sep 17 00:00:00 2001 From: wKLV Date: Mon, 4 Nov 2013 00:16:36 +0100 Subject: [PATCH 2/3] Check type uses the static values --- src/input/Mouse.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/input/Mouse.js b/src/input/Mouse.js index 6abbd983..2ad0683d 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -63,6 +63,11 @@ Phaser.Mouse = function (game) { }; +/** +* @constant +* @type {number} +*/ +Phaser.Mouse.NO_BUTTON = -1; /** * @constant * @type {number} @@ -81,6 +86,7 @@ Phaser.Mouse.MIDDLE_BUTTON = 1; */ Phaser.Mouse.RIGHT_BUTTON = 2; + Phaser.Mouse.prototype = { /** @@ -124,7 +130,9 @@ Phaser.Mouse.prototype = { event.preventDefault(); - this.mouseTypeDown = event.which - 1; + if (event.which === 1) this.mouseTypeDown = Phaser.Mouse.LEFT_BUTTON; + else if (event.which === 2) this.mouseTypeDown = Phaser.Mouse.MIDDLE_BUTON; + else if (event.which === 3) this.mouseTypeDown = Phaser.Mouse.RIGHT_BUTTON; if (this.mouseDownCallback) { @@ -176,7 +184,7 @@ Phaser.Mouse.prototype = { event.preventDefault(); - this.mouseTypeDown = -1; + this.mouseTypeDown = Phaser.Mouse.NO_BUTTON; if (this.mouseUpCallback) { From 8678373754e16a395a52a917ac5e1220ba3b7ba6 Mon Sep 17 00:00:00 2001 From: wKLV Date: Mon, 4 Nov 2013 00:18:59 +0100 Subject: [PATCH 3/3] fix typo --- src/input/Mouse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/Mouse.js b/src/input/Mouse.js index 2ad0683d..5734dc35 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -131,7 +131,7 @@ Phaser.Mouse.prototype = { event.preventDefault(); if (event.which === 1) this.mouseTypeDown = Phaser.Mouse.LEFT_BUTTON; - else if (event.which === 2) this.mouseTypeDown = Phaser.Mouse.MIDDLE_BUTON; + else if (event.which === 2) this.mouseTypeDown = Phaser.Mouse.MIDDLE_BUTTON; else if (event.which === 3) this.mouseTypeDown = Phaser.Mouse.RIGHT_BUTTON; if (this.mouseDownCallback)