1
1
/* eslint-env browser */
2
2
3
- 'use strict' ;
4
3
5
4
var dispatchGridEvent = require ( '../lib/dispatchGridEvent' ) ;
6
5
var Button = require ( '../cellRenderers/Button' ) ;
@@ -96,6 +95,10 @@ exports.mixin = {
96
95
} , this ) ;
97
96
} ,
98
97
98
+ /**
99
+ * @param {boolean } allow
100
+ * @this {any}
101
+ */
99
102
allowEvents : function ( allow ) {
100
103
this . allowEventHandlers = ! ! allow ;
101
104
@@ -206,7 +209,7 @@ exports.mixin = {
206
209
/**
207
210
* @memberOf Hypergrid#
208
211
* @desc Synthesize and fire a `fin-context-menu` event
209
- * @param {keyEvent } event - The canvas event.
212
+ * @param {KeyboardEvent } event - The canvas event.
210
213
* @returns {boolean } Proceed; event was not [canceled](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent#Return_Value `EventTarget.dispatchEvent`).
211
214
*/
212
215
fireSyntheticContextMenuEvent : function ( event ) {
@@ -419,7 +422,7 @@ exports.mixin = {
419
422
* @desc Synthesize and fire a fin-request-cell-edit event.
420
423
*
421
424
* This event is cancelable.
422
- * @param {CellEvent } cellEvent
425
+ * @param {unknown } cellEvent
423
426
* @param {* } value
424
427
* @returns {boolean } Proceed; event was not [canceled](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent#Return_Value `EventTarget.dispatchEvent`).
425
428
*/
@@ -446,7 +449,6 @@ exports.mixin = {
446
449
447
450
/**
448
451
* @memberOf Hypergrid#
449
- * @returns {Renderer } sub-component
450
452
* @param {Point } cell - The x,y coordinates.
451
453
* @param {Object } oldValue - The old value.
452
454
* @param {Object } newValue - The new value.
@@ -533,121 +535,45 @@ exports.mixin = {
533
535
return ;
534
536
}
535
537
536
- handleMouseEvent ( e , function ( mouseEvent ) {
537
- mouseEvent . keys = e . detail . keys ;
538
- this . mouseDownState = mouseEvent ;
539
- this . delegateMouseDown ( mouseEvent ) ;
540
- this . fireSyntheticMouseDownEvent ( mouseEvent ) ;
541
- this . repaint ( ) ;
542
- } ) ;
538
+ handleMouseEvent ( e ,
539
+ /**
540
+ * @this {any}
541
+ * @param {any } mouseEvent
542
+ */
543
+ function ( mouseEvent ) {
544
+ mouseEvent . keys = e . detail . keys ;
545
+ this . mouseDownState = mouseEvent ;
546
+ this . delegateMouseDown ( mouseEvent ) ;
547
+ this . fireSyntheticMouseDownEvent ( mouseEvent ) ;
548
+ this . repaint ( ) ;
549
+ }
550
+ ) ;
543
551
} ) ;
544
552
545
553
this . addInternalEventListener ( 'fin-canvas-click' , function ( e ) {
546
554
if ( grid . properties . readOnly ) {
547
555
return ;
548
556
}
549
- handleMouseEvent ( e , function ( mouseEvent ) {
550
- var isMouseDownCell = this . mouseDownState && this . mouseDownState . gridCell . equals ( mouseEvent . gridCell ) ;
551
- if ( isMouseDownCell && mouseEvent . mousePointInClickRect ) {
552
- mouseEvent . keys = e . detail . keys ; // todo: this was in fin-tap but wasn't here
553
- if ( this . mouseDownState ) {
554
- this . fireSyntheticButtonPressedEvent ( this . mouseDownState ) ;
557
+ handleMouseEvent ( e ,
558
+ /**
559
+ * @this {any}
560
+ * @param {{ gridCell: any; mousePointInClickRect: any; keys: any; } } mouseEvent
561
+ */
562
+ function ( mouseEvent ) {
563
+ var isMouseDownCell = this . mouseDownState && this . mouseDownState . gridCell . equals ( mouseEvent . gridCell ) ;
564
+ if ( isMouseDownCell && mouseEvent . mousePointInClickRect ) {
565
+ mouseEvent . keys = e . detail . keys ; // todo: this was in fin-tap but wasn't here
566
+ if ( this . mouseDownState ) {
567
+ this . fireSyntheticButtonPressedEvent ( this . mouseDownState ) ;
568
+ }
569
+ this . fireSyntheticClickEvent ( mouseEvent ) ;
570
+ this . delegateClick ( mouseEvent ) ;
555
571
}
556
- this . fireSyntheticClickEvent ( mouseEvent ) ;
557
- this . delegateClick ( mouseEvent ) ;
572
+ this . mouseDownState = null ;
558
573
}
559
- this . mouseDownState = null ;
560
- } ) ;
561
- } ) ;
562
-
563
- this . addInternalEventListener ( 'fin-canvas-mouseup' , function ( e ) {
564
- if ( grid . properties . readOnly ) {
565
- return ;
566
- }
567
- grid . dragging = false ;
568
- if ( grid . isScrollingNow ( ) ) {
569
- grid . setScrollingNow ( false ) ;
570
- }
571
- if ( grid . columnDragAutoScrolling ) {
572
- grid . columnDragAutoScrolling = false ;
573
- }
574
- handleMouseEvent ( e , function ( mouseEvent ) {
575
- this . delegateMouseUp ( mouseEvent ) ;
576
- this . fireSyntheticMouseUpEvent ( mouseEvent ) ;
577
- } ) ;
578
- } ) ;
579
-
580
- this . addInternalEventListener ( 'fin-canvas-dblclick' , function ( e ) {
581
- if ( grid . properties . readOnly ) {
582
- return ;
583
- }
584
- handleMouseEvent ( e , function ( mouseEvent ) {
585
- this . fireSyntheticDoubleClickEvent ( mouseEvent , e ) ;
586
- this . delegateDoubleClick ( mouseEvent ) ;
587
- } ) ;
588
- } ) ;
589
-
590
- this . addInternalEventListener ( 'fin-canvas-drag' , function ( e ) {
591
- if ( grid . properties . readOnly ) {
592
- return ;
593
- }
594
- grid . dragging = true ;
595
- handleMouseEvent ( e , grid . delegateMouseDrag ) ;
574
+ ) ;
596
575
} ) ;
597
576
598
- this . addInternalEventListener ( 'fin-canvas-keydown' , function ( e ) {
599
- if ( grid . properties . readOnly ) {
600
- return ;
601
- }
602
- grid . fireSyntheticKeydownEvent ( e ) ;
603
- grid . delegateKeyDown ( e ) ;
604
- } ) ;
605
-
606
- this . addInternalEventListener ( 'fin-canvas-keyup' , function ( e ) {
607
- if ( grid . properties . readOnly ) {
608
- return ;
609
- }
610
- grid . fireSyntheticKeyupEvent ( e ) ;
611
- grid . delegateKeyUp ( e ) ;
612
- } ) ;
613
-
614
- this . addInternalEventListener ( 'fin-canvas-wheelmoved' , function ( e ) {
615
- handleMouseEvent ( e , grid . delegateWheelMoved ) ;
616
- } ) ;
617
-
618
- this . addInternalEventListener ( 'fin-canvas-mouseout' , function ( e ) {
619
- if ( grid . properties . readOnly ) {
620
- return ;
621
- }
622
- handleMouseEvent ( e , grid . delegateMouseExit ) ;
623
- } ) ;
624
-
625
- this . addInternalEventListener ( 'fin-canvas-context-menu' , function ( e ) {
626
- handleMouseEvent ( e , function ( mouseEvent ) {
627
- grid . delegateContextMenu ( mouseEvent ) ;
628
- grid . fireSyntheticContextMenuEvent ( mouseEvent ) ;
629
- } ) ;
630
- } ) ;
631
-
632
- this . addInternalEventListener ( 'fin-canvas-touchstart' , function ( e ) {
633
- grid . delegateTouchStart ( e ) ;
634
- grid . fireSyntheticTouchStartEvent ( e ) ;
635
- } ) ;
636
-
637
- this . addInternalEventListener ( 'fin-canvas-touchmove' , function ( e ) {
638
- grid . delegateTouchMove ( e ) ;
639
- grid . fireSyntheticTouchMoveEvent ( e ) ;
640
- } ) ;
641
-
642
- this . addInternalEventListener ( 'fin-canvas-touchend' , function ( e ) {
643
- grid . delegateTouchEnd ( e ) ;
644
- grid . fireSyntheticTouchEndEvent ( e ) ;
645
- } ) ;
646
-
647
- //Register a listener for the copy event so we can copy our selected region to the pastebuffer if conditions are right.
648
- document . body . addEventListener ( 'copy' , function ( evt ) {
649
- grid . checkClipboardCopy ( evt ) ;
650
- } ) ;
651
577
} ,
652
578
653
579
/**
@@ -680,7 +606,7 @@ exports.mixin = {
680
606
/**
681
607
* @memberOf Hypergrid#
682
608
* @desc Delegate MouseMove to the behavior (model).
683
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
609
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
684
610
*/
685
611
delegateMouseMove : function ( mouseDetails ) {
686
612
this . behavior . onMouseMove ( this , mouseDetails ) ;
@@ -689,7 +615,7 @@ exports.mixin = {
689
615
/**
690
616
* @memberOf Hypergrid#
691
617
* @desc Delegate mousedown to the behavior (model).
692
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
618
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
693
619
*/
694
620
delegateMouseDown : function ( mouseDetails ) {
695
621
this . behavior . handleMouseDown ( this , mouseDetails ) ;
@@ -698,7 +624,7 @@ exports.mixin = {
698
624
/**
699
625
* @memberOf Hypergrid#
700
626
* @desc Delegate mouseup to the behavior (model).
701
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
627
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
702
628
*/
703
629
delegateMouseUp : function ( mouseDetails ) {
704
630
this . behavior . onMouseUp ( this , mouseDetails ) ;
@@ -707,7 +633,7 @@ exports.mixin = {
707
633
/**
708
634
* @memberOf Hypergrid#
709
635
* @desc Delegate click to the behavior (model).
710
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
636
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
711
637
*/
712
638
delegateClick : function ( mouseDetails ) {
713
639
this . behavior . onClick ( this , mouseDetails ) ;
@@ -716,7 +642,7 @@ exports.mixin = {
716
642
/**
717
643
* @memberOf Hypergrid#
718
644
* @desc Delegate mouseDrag to the behavior (model).
719
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
645
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
720
646
*/
721
647
delegateMouseDrag : function ( mouseDetails ) {
722
648
this . behavior . onMouseDrag ( this , mouseDetails ) ;
@@ -725,7 +651,7 @@ exports.mixin = {
725
651
/**
726
652
* @memberOf Hypergrid#
727
653
* @desc We've been doubleclicked on. Delegate through the behavior (model).
728
- * @param {mouseDetails } mouseDetails - An enriched mouse event from fin-canvas.
654
+ * @param {unknown } mouseDetails - An enriched mouse event from fin-canvas.
729
655
*/
730
656
delegateDoubleClick : function ( mouseDetails ) {
731
657
this . behavior . onDoubleClick ( this , mouseDetails ) ;
0 commit comments