Mouse.button and MSPointer.button properties removed and jsdocs expanded to explain the correct path to now take (#1903)

This commit is contained in:
Richard Davey 2015-07-12 11:47:20 +01:00
parent 4dec046c40
commit b0a8d3d78c
4 changed files with 13 additions and 14 deletions

View file

@ -244,6 +244,7 @@ Version 2.4 - "Katar" - in dev
* Button game objects now have `Input.useHandCursor` set to `true` by default.
* Phaser.BitmapText no longer extends PIXI.BitmapText but replaces it entirely.
* Phaser.Text no longer extends PIXI.Text but replaces it entirely. Phaser.Text now natively extends a Phaser Sprite, meaning it can be enabled for physics, damaged, etc.
* Mouse.button and MSPointer.button have been removed. They never supported complex button events (such as holding down 2 buttons and releasing just one) or any buttons other than left and right. They have been replaced with the far more robust and accurate Pointer button properties such as `Pointer.leftButton`, `Pointer.rightButton` and so on.
### New Features

View file

@ -49,8 +49,9 @@ Phaser.MSPointer = function (game) {
this.capture = true;
/**
* @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.
* @default
* This property was removed in Phaser 2.4 and should no longer be used.
* Instead please see the Pointer button properties such as `Pointer.leftButton`, `Pointer.rightButton` and so on.
* @property {number} button
*/
this.button = -1;
@ -149,8 +150,6 @@ Phaser.MSPointer.prototype = {
event.preventDefault();
}
this.button = event.button;
if (this.pointerDownCallback)
{
this.pointerDownCallback.call(this.callbackContext, event);
@ -211,8 +210,6 @@ Phaser.MSPointer.prototype = {
event.preventDefault();
}
this.button = Phaser.Mouse.NO_BUTTON;
if (this.pointerUpCallback)
{
this.pointerUpCallback.call(this.callbackContext, event);

View file

@ -59,7 +59,9 @@ Phaser.Mouse = function (game) {
this.capture = false;
/**
* @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.
* This property was removed in Phaser 2.4 and should no longer be used.
* Instead please see the Pointer button properties such as `Pointer.leftButton`, `Pointer.rightButton` and so on.
* @property {number} button
* @default
*/
this.button = -1;
@ -276,8 +278,6 @@ Phaser.Mouse.prototype = {
event.preventDefault();
}
this.button = event.button;
if (this.mouseDownCallback)
{
this.mouseDownCallback.call(this.callbackContext, event);
@ -338,8 +338,6 @@ Phaser.Mouse.prototype = {
event.preventDefault();
}
this.button = Phaser.Mouse.NO_BUTTON;
if (this.mouseUpCallback)
{
this.mouseUpCallback.call(this.callbackContext, event);
@ -366,8 +364,6 @@ Phaser.Mouse.prototype = {
if (!this.game.input.mousePointer.withinGame)
{
this.button = Phaser.Mouse.NO_BUTTON;
if (this.mouseUpCallback)
{
this.mouseUpCallback.call(this.callbackContext, event);

View file

@ -55,7 +55,10 @@ Phaser.Pointer = function (game, id) {
this.target = null;
/**
* @property {any} button - The button property of the most recent event as set by the DOM event when this Pointer is started.
* The button property of the most recent DOM event when this Pointer is started.
* You should not rely on this value for accurate button detection, instead use the Pointer properties
* `leftButton`, `rightButton`, `middleButton` and so on.
* @property {any} button
* @default
*/
this.button = null;
@ -390,6 +393,8 @@ Phaser.Pointer.prototype = {
*/
updateButtons: function (event) {
this.button = event.button;
var buttons = event.buttons;
if (typeof buttons === 'undefined')