diff --git a/src/input/Mouse.js b/src/input/Mouse.js index 3a781c01..5734dc35 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. @@ -58,6 +63,11 @@ Phaser.Mouse = function (game) { }; +/** +* @constant +* @type {number} +*/ +Phaser.Mouse.NO_BUTTON = -1; /** * @constant * @type {number} @@ -76,6 +86,7 @@ Phaser.Mouse.MIDDLE_BUTTON = 1; */ Phaser.Mouse.RIGHT_BUTTON = 2; + Phaser.Mouse.prototype = { /** @@ -119,6 +130,10 @@ 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_BUTTON; + else if (event.which === 3) this.mouseTypeDown = Phaser.Mouse.RIGHT_BUTTON; + if (this.mouseDownCallback) { this.mouseDownCallback.call(this.callbackContext, event); @@ -169,6 +184,8 @@ Phaser.Mouse.prototype = { event.preventDefault(); + this.mouseTypeDown = Phaser.Mouse.NO_BUTTON; + if (this.mouseUpCallback) { this.mouseUpCallback.call(this.callbackContext, event); @@ -262,4 +279,4 @@ Phaser.Mouse.prototype = { } -}; \ No newline at end of file +};