diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index ce2a062..3998b67 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -381,22 +381,29 @@ //stage.__i var length = this.interactiveItems.length; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + var downFunction = isRightButton ? 'rightdown' : 'mousedown'; + var clickFunction = isRightButton ? 'rightclick' : 'click'; + var buttonIsDown = isRightButton ? '__rightIsDown' : '__mouseIsDown'; + var isDown = isRightButton ? '__isRightDown' : '__isDown'; + // while // hit test for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(item.mousedown || item.click) + if(item[downFunction] || item[clickFunction]) { - item.__mouseIsDown = true; + item[buttonIsDown] = true; item.__hit = this.hitTest(item, this.mouse); if(item.__hit) { //call the function! - if(item.mousedown)item.mousedown(this.mouse); - item.__isDown = true; + if(item[downFunction])item[downFunction](this.mouse); + item[isDown] = true; // just the one! if(!item.interactiveChildren)break; @@ -462,36 +469,46 @@ var length = this.interactiveItems.length; var up = false; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + + var upFunction = isRightButton ? 'rightup' : 'mouseup'; + var clickFunction = isRightButton ? 'rightclick' : 'click'; + var upOutsideFunction = isRightButton ? 'rightupoutside' : 'mouseupoutside'; + var isDown = isRightButton ? '__isRightDown' : '__isDown'; + for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - item.__hit = this.hitTest(item, this.mouse); - - if(item.__hit && !up) + if(item[clickFunction] || item[upFunction] || item[upOutsideFunction]) { - //call the function! - if(item.mouseup) + item.__hit = this.hitTest(item, this.mouse); + + if(item.__hit && !up) { - item.mouseup(this.mouse); + //call the function! + if(item[upFunction]) + { + item[upFunction](this.mouse); + } + if(item[isDown]) + { + if(item[clickFunction])item[clickFunction](this.mouse); + } + + if(!item.interactiveChildren)up = true; } - if(item.__isDown) + else { - if(item.click)item.click(this.mouse); + if(item[isDown]) + { + if(item[upOutsideFunction])item[upOutsideFunction](this.mouse); + } } - if(!item.interactiveChildren)up = true; + item[isDown] = false; } - else - { - if(item.__isDown) - { - if(item.mouseupoutside)item.mouseupoutside(this.mouse); - } - } - - item.__isDown = false; - //} } }; diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index ce2a062..3998b67 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -381,22 +381,29 @@ //stage.__i var length = this.interactiveItems.length; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + var downFunction = isRightButton ? 'rightdown' : 'mousedown'; + var clickFunction = isRightButton ? 'rightclick' : 'click'; + var buttonIsDown = isRightButton ? '__rightIsDown' : '__mouseIsDown'; + var isDown = isRightButton ? '__isRightDown' : '__isDown'; + // while // hit test for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(item.mousedown || item.click) + if(item[downFunction] || item[clickFunction]) { - item.__mouseIsDown = true; + item[buttonIsDown] = true; item.__hit = this.hitTest(item, this.mouse); if(item.__hit) { //call the function! - if(item.mousedown)item.mousedown(this.mouse); - item.__isDown = true; + if(item[downFunction])item[downFunction](this.mouse); + item[isDown] = true; // just the one! if(!item.interactiveChildren)break; @@ -462,36 +469,46 @@ var length = this.interactiveItems.length; var up = false; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + + var upFunction = isRightButton ? 'rightup' : 'mouseup'; + var clickFunction = isRightButton ? 'rightclick' : 'click'; + var upOutsideFunction = isRightButton ? 'rightupoutside' : 'mouseupoutside'; + var isDown = isRightButton ? '__isRightDown' : '__isDown'; + for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - item.__hit = this.hitTest(item, this.mouse); - - if(item.__hit && !up) + if(item[clickFunction] || item[upFunction] || item[upOutsideFunction]) { - //call the function! - if(item.mouseup) + item.__hit = this.hitTest(item, this.mouse); + + if(item.__hit && !up) { - item.mouseup(this.mouse); + //call the function! + if(item[upFunction]) + { + item[upFunction](this.mouse); + } + if(item[isDown]) + { + if(item[clickFunction])item[clickFunction](this.mouse); + } + + if(!item.interactiveChildren)up = true; } - if(item.__isDown) + else { - if(item.click)item.click(this.mouse); + if(item[isDown]) + { + if(item[upOutsideFunction])item[upOutsideFunction](this.mouse); + } } - if(!item.interactiveChildren)up = true; + item[isDown] = false; } - else - { - if(item.__isDown) - { - if(item.mouseupoutside)item.mouseupoutside(this.mouse); - } - } - - item.__isDown = false; - //} } }; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 45ffa33..4a7b132 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -203,33 +203,7 @@ /* * MOUSE Callbacks */ - - /** - * A callback that is used when the users clicks on the displayObject with their mouse - * @method click - * @param interactionData {InteractionData} - */ - - /** - * A callback that is used when the user clicks the mouse down over the sprite - * @method mousedown - * @param interactionData {InteractionData} - */ - - /** - * A callback that is used when the user releases the mouse that was over the displayObject - * for this callback to be fired the mouse must have been pressed down over the displayObject - * @method mouseup - * @param interactionData {InteractionData} - */ - - /** - * A callback that is used when the user releases the mouse that was over the displayObject but is no longer over the displayObject - * for this callback to be fired, The touch must have started over the displayObject - * @method mouseupoutside - * @param interactionData {InteractionData} - */ - + /** * A callback that is used when the users mouse rolls over the displayObject * @method mouseover @@ -242,6 +216,59 @@ * @param interactionData {InteractionData} */ + //Left button + /** + * A callback that is used when the users clicks on the displayObject with their mouse's left button + * @method click + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user clicks the mouse's left button down over the sprite + * @method mousedown + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user releases the mouse's left button that was over the displayObject + * for this callback to be fired, the mouse's left button must have been pressed down over the displayObject + * @method mouseup + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user releases the mouse's left button that was over the displayObject but is no longer over the displayObject + * for this callback to be fired, the mouse's left button must have been pressed down over the displayObject + * @method mouseupoutside + * @param interactionData {InteractionData} + */ + + //Right button + /** + * A callback that is used when the users clicks on the displayObject with their mouse's right button + * @method rightclick + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user clicks the mouse's right button down over the sprite + * @method rightdown + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user releases the mouse's right button that was over the displayObject + * for this callback to be fired the mouse's right button must have been pressed down over the displayObject + * @method rightup + * @param interactionData {InteractionData} + */ + + /** + * A callback that is used when the user releases the mouse's right button that was over the displayObject but is no longer over the displayObject + * for this callback to be fired, the mouse's right button must have been pressed down over the displayObject + * @method rightupoutside + * @param interactionData {InteractionData} + */ /* * TOUCH Callbacks