diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 5b4eb78..b3096d7 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -381,22 +381,45 @@ //stage.__i var length = this.interactiveItems.length; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + var downFunction; + var clickFunction; + var buttonIsDown; + var isDown; + // while // hit test for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(item.mousedown || item.click) + //Left button + if(!isRightButton) { - item.__mouseIsDown = true; + downFunction = 'mousedown'; + clickFunction = 'click'; + buttonIsDown = '__mouseIsDown'; + isDown = '__isDown'; + } + else //Right button + { + downFunction = 'rightdown'; + clickFunction = 'rightclick'; + buttonIsDown = '__rightIsDown'; + isDown = '__isRightDown'; + } + + if(item[downFunction] || item[clickFunction]) + { + 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 +485,62 @@ var length = this.interactiveItems.length; var up = false; + var e = this.mouse.originalEvent; + var isRightButton = e.button === 2 || e.which === 3; + var upFunction; + var upOutsideFunction; + var clickFunction; + var isDown; + for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - item.__hit = this.hitTest(item, this.mouse); - - if(item.__hit && !up) + //Left button + if(!isRightButton) { - //call the function! - if(item.mouseup) - { - item.mouseup(this.mouse); - } - if(item.__isDown) - { - if(item.click)item.click(this.mouse); - } - - if(!item.interactiveChildren)up = true; + upFunction = 'mouseup'; + upOutsideFunction = 'mouseupoutside'; + clickFunction = 'click'; + isDown = '__isDown'; } else { - if(item.__isDown) - { - if(item.mouseupoutside)item.mouseupoutside(this.mouse); - } + //Right button + upFunction = 'rightup'; + upOutsideFunction = 'rightupoutside'; + clickFunction = 'rightclick'; + isDown = '__isRightDown'; } - item.__isDown = false; - //} + if(item[clickFunction] || item[upFunction] || item[upOutsideFunction]) + { + item.__hit = this.hitTest(item, this.mouse); + + if(item.__hit && !up) + { + //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; + } + else + { + if(item[isDown]) + { + if(item[upOutsideFunction])item[upOutsideFunction](this.mouse); + } + } + + item[isDown] = false; + } } };