@@ -349,13 +349,15 @@ cc.MouseHandler.create = function (delegate, priority) {
349
349
350
350
cc . MouseDispatcher = cc . Class . extend ( {
351
351
_mousePressed :false ,
352
+ _rightMousePressed :false ,
352
353
_mouseDelegateHandlers :null ,
353
354
_dispatchEvents :false ,
354
355
355
356
init :function ( ) {
356
357
this . _dispatchEvents = true ;
357
358
this . _mouseDelegateHandlers = [ ] ;
358
359
this . _mousePressed = false ;
360
+ this . _rightMousePressed = false ;
359
361
360
362
cc . MouseDispatcher . _registerHtmlElementEvent ( cc . canvas ) ;
361
363
return true ;
@@ -368,6 +370,14 @@ cc.MouseDispatcher = cc.Class.extend({
368
370
_getMousePressed :function ( ) {
369
371
return this . _mousePressed ;
370
372
} ,
373
+
374
+ _setRightMousePressed :function ( pressed ) {
375
+ this . _rightMousePressed = pressed ;
376
+ } ,
377
+
378
+ _getRightMousePressed :function ( ) {
379
+ return this . _rightMousePressed ;
380
+ } ,
371
381
372
382
/**
373
383
* Adds a mouse delegate to the dispatcher's list. <br/>
@@ -455,17 +465,32 @@ cc.MouseDispatcher = cc.Class.extend({
455
465
456
466
switch ( index ) {
457
467
case cc . MOUSE_DOWN :
458
- if ( handler . getDelegate ( ) . onMouseDown )
459
- handler . getDelegate ( ) . onMouseDown ( mouseObj ) ;
468
+ if ( mouseObj . getButton ( ) == cc . MOUSE_RIGHTBUTTON ) {
469
+ if ( handler . getDelegate ( ) . onRightMouseDown ) ;
470
+ handler . getDelegate ( ) . onRightMouseDown ( mouseObj ) ;
471
+ }
472
+ else {
473
+ if ( handler . getDelegate ( ) . onMouseDown )
474
+ handler . getDelegate ( ) . onMouseDown ( mouseObj ) ;
475
+ }
460
476
break ;
461
477
case cc . MOUSE_UP :
462
- if ( handler . getDelegate ( ) . onMouseUp )
463
- handler . getDelegate ( ) . onMouseUp ( mouseObj ) ;
478
+ if ( mouseObj . getButton ( ) == cc . MOUSE_RIGHTBUTTON ) {
479
+ if ( handler . getDelegate ( ) . onRightMouseUp ) ;
480
+ handler . getDelegate ( ) . onRightMouseUp ( mouseObj ) ;
481
+ }
482
+ else {
483
+ if ( handler . getDelegate ( ) . onMouseUp )
484
+ handler . getDelegate ( ) . onMouseUp ( mouseObj ) ;
485
+ }
464
486
break ;
465
487
case cc . MOUSE_MOVED :
466
- if ( this . _mousePressed ) {
488
+ if ( this . _mousePressed ) {
467
489
if ( handler . getDelegate ( ) . onMouseDragged )
468
490
handler . getDelegate ( ) . onMouseDragged ( mouseObj ) ;
491
+ } else if ( this . _rightMousePressed ) {
492
+ if ( handler . getDelegate ( ) . onRightMouseDragged )
493
+ handler . getDelegate ( ) . onRightMouseDragged ( mouseObj ) ;
469
494
} else {
470
495
if ( handler . getDelegate ( ) . onMouseMoved )
471
496
handler . getDelegate ( ) . onMouseMoved ( mouseObj ) ;
@@ -497,11 +522,21 @@ cc.MouseDispatcher._registerHtmlElementEvent = function (element) {
497
522
return ;
498
523
499
524
window . addEventListener ( 'mousedown' , function ( event ) {
500
- cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setMousePressed ( true ) ;
525
+ if ( event . button == cc . MOUSE_RIGHTBUTTON ) {
526
+ cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setRightMousePressed ( true ) ;
527
+ }
528
+ else {
529
+ cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setMousePressed ( true ) ;
530
+ }
501
531
} ) ;
502
532
503
533
window . addEventListener ( 'mouseup' , function ( event ) {
504
- cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setMousePressed ( false ) ;
534
+ if ( event . button == cc . MOUSE_RIGHTBUTTON ) {
535
+ cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setRightMousePressed ( false ) ;
536
+ }
537
+ else {
538
+ cc . Director . getInstance ( ) . getMouseDispatcher ( ) . _setMousePressed ( false ) ;
539
+ }
505
540
} ) ;
506
541
507
542
function getMouseByEvent ( event ) {
0 commit comments