@@ -381,22 +381,29 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
381381 //stage.__i
382382 var length = this . interactiveItems . length ;
383383
384+ var e = this . mouse . originalEvent ;
385+ var isRightButton = e . button === 2 || e . which === 3 ;
386+ var downFunction = isRightButton ? 'rightdown' : 'mousedown' ;
387+ var clickFunction = isRightButton ? 'rightclick' : 'click' ;
388+ var buttonIsDown = isRightButton ? '__rightIsDown' : '__mouseIsDown' ;
389+ var isDown = isRightButton ? '__isRightDown' : '__isDown' ;
390+
384391 // while
385392 // hit test
386393 for ( var i = 0 ; i < length ; i ++ )
387394 {
388395 var item = this . interactiveItems [ i ] ;
389396
390- if ( item . mousedown || item . click )
397+ if ( item [ downFunction ] || item [ clickFunction ] )
391398 {
392- item . __mouseIsDown = true ;
399+ item [ buttonIsDown ] = true ;
393400 item . __hit = this . hitTest ( item , this . mouse ) ;
394401
395402 if ( item . __hit )
396403 {
397404 //call the function!
398- if ( item . mousedown ) item . mousedown ( this . mouse ) ;
399- item . __isDown = true ;
405+ if ( item [ downFunction ] ) item [ downFunction ] ( this . mouse ) ;
406+ item [ isDown ] = true ;
400407
401408 // just the one!
402409 if ( ! item . interactiveChildren ) break ;
@@ -412,13 +419,15 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
412419 * @param event {Event} The DOM event of a mouse button being moved out
413420 * @private
414421 */
415- PIXI . InteractionManager . prototype . onMouseOut = function ( )
422+ PIXI . InteractionManager . prototype . onMouseOut = function ( event )
416423{
417424 if ( this . dirty )
418425 {
419426 this . rebuildInteractiveGraph ( ) ;
420427 }
421428
429+ this . mouse . originalEvent = event || window . event ; //IE uses window.event
430+
422431 var length = this . interactiveItems . length ;
423432
424433 this . interactionDOMElement . style . cursor = 'inherit' ;
@@ -460,36 +469,46 @@ PIXI.InteractionManager.prototype.onMouseUp = function(event)
460469 var length = this . interactiveItems . length ;
461470 var up = false ;
462471
472+ var e = this . mouse . originalEvent ;
473+ var isRightButton = e . button === 2 || e . which === 3 ;
474+
475+ var upFunction = isRightButton ? 'rightup' : 'mouseup' ;
476+ var clickFunction = isRightButton ? 'rightclick' : 'click' ;
477+ var upOutsideFunction = isRightButton ? 'rightupoutside' : 'mouseupoutside' ;
478+ var isDown = isRightButton ? '__isRightDown' : '__isDown' ;
479+
463480 for ( var i = 0 ; i < length ; i ++ )
464481 {
465482 var item = this . interactiveItems [ i ] ;
466483
467- item . __hit = this . hitTest ( item , this . mouse ) ;
468-
469- if ( item . __hit && ! up )
484+ if ( item [ clickFunction ] || item [ upFunction ] || item [ upOutsideFunction ] )
470485 {
471- //call the function!
472- if ( item . mouseup )
486+ item . __hit = this . hitTest ( item , this . mouse ) ;
487+
488+ if ( item . __hit && ! up )
473489 {
474- item . mouseup ( this . mouse ) ;
490+ //call the function!
491+ if ( item [ upFunction ] )
492+ {
493+ item [ upFunction ] ( this . mouse ) ;
494+ }
495+ if ( item [ isDown ] )
496+ {
497+ if ( item [ clickFunction ] ) item [ clickFunction ] ( this . mouse ) ;
498+ }
499+
500+ if ( ! item . interactiveChildren ) up = true ;
475501 }
476- if ( item . __isDown )
502+ else
477503 {
478- if ( item . click ) item . click ( this . mouse ) ;
504+ if ( item [ isDown ] )
505+ {
506+ if ( item [ upOutsideFunction ] ) item [ upOutsideFunction ] ( this . mouse ) ;
507+ }
479508 }
480509
481- if ( ! item . interactiveChildren ) up = true ;
510+ item [ isDown ] = false ;
482511 }
483- else
484- {
485- if ( item . __isDown )
486- {
487- if ( item . mouseupoutside ) item . mouseupoutside ( this . mouse ) ;
488- }
489- }
490-
491- item . __isDown = false ;
492- //}
493512 }
494513} ;
495514
@@ -596,7 +615,8 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
596615 // update the touch position
597616 touchData . global . x = ( touchEvent . clientX - rect . left ) * ( this . target . width / rect . width ) ;
598617 touchData . global . y = ( touchEvent . clientY - rect . top ) * ( this . target . height / rect . height ) ;
599- if ( navigator . isCocoonJS ) {
618+ if ( navigator . isCocoonJS && ! rect . left && ! rect . top && ! event . target . style . width && ! event . target . style . height ) {
619+ //Support for CocoonJS fullscreen scale modes
600620 touchData . global . x = touchEvent . clientX ;
601621 touchData . global . y = touchEvent . clientY ;
602622 }
@@ -640,7 +660,8 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
640660 this . touchs [ touchEvent . identifier ] = touchData ;
641661 touchData . global . x = ( touchEvent . clientX - rect . left ) * ( this . target . width / rect . width ) ;
642662 touchData . global . y = ( touchEvent . clientY - rect . top ) * ( this . target . height / rect . height ) ;
643- if ( navigator . isCocoonJS ) {
663+ if ( navigator . isCocoonJS && ! rect . left && ! rect . top && ! event . target . style . width && ! event . target . style . height ) {
664+ //Support for CocoonJS fullscreen scale modes
644665 touchData . global . x = touchEvent . clientX ;
645666 touchData . global . y = touchEvent . clientY ;
646667 }
@@ -695,7 +716,8 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
695716 var up = false ;
696717 touchData . global . x = ( touchEvent . clientX - rect . left ) * ( this . target . width / rect . width ) ;
697718 touchData . global . y = ( touchEvent . clientY - rect . top ) * ( this . target . height / rect . height ) ;
698- if ( navigator . isCocoonJS ) {
719+ if ( navigator . isCocoonJS && ! rect . left && ! rect . top && ! event . target . style . width && ! event . target . style . height ) {
720+ //Support for CocoonJS fullscreen scale modes
699721 touchData . global . x = touchEvent . clientX ;
700722 touchData . global . y = touchEvent . clientY ;
701723 }
0 commit comments