@@ -204,6 +204,10 @@ function vtkRenderWindowInteractor(publicAPI, model) {
204
204
return keys ;
205
205
}
206
206
207
+ function getDeviceTypeFor ( event ) {
208
+ return event . pointerType || '' ;
209
+ }
210
+
207
211
publicAPI . bindEvents = ( container ) => {
208
212
model . container = container ;
209
213
container . addEventListener ( 'contextmenu' , preventDefault ) ;
@@ -286,18 +290,24 @@ function vtkRenderWindowInteractor(publicAPI, model) {
286
290
const callData = {
287
291
...getModifierKeysFor ( event ) ,
288
292
position : getScreenEventPositionFor ( event ) ,
293
+ deviceType : getDeviceTypeFor ( event ) ,
289
294
} ;
290
295
publicAPI . pointerEnterEvent ( callData ) ;
291
- publicAPI . mouseEnterEvent ( callData ) ;
296
+ if ( callData . deviceType === 'mouse' ) {
297
+ publicAPI . mouseEnterEvent ( callData ) ;
298
+ }
292
299
} ;
293
300
294
301
publicAPI . handlePointerLeave = ( event ) => {
295
302
const callData = {
296
303
...getModifierKeysFor ( event ) ,
297
304
position : getScreenEventPositionFor ( event ) ,
305
+ deviceType : getDeviceTypeFor ( event ) ,
298
306
} ;
299
307
publicAPI . pointerLeaveEvent ( callData ) ;
300
- publicAPI . mouseLeaveEvent ( callData ) ;
308
+ if ( callData . deviceType === 'mouse' ) {
309
+ publicAPI . mouseLeaveEvent ( callData ) ;
310
+ }
301
311
} ;
302
312
303
313
publicAPI . handlePointerDown = ( event ) => {
@@ -392,6 +402,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
392
402
const callData = {
393
403
...getModifierKeysFor ( event ) ,
394
404
position : getScreenEventPositionFor ( event ) ,
405
+ deviceType : getDeviceTypeFor ( event ) ,
395
406
} ;
396
407
switch ( event . button ) {
397
408
case 0 :
@@ -591,6 +602,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
591
602
const callData = {
592
603
...getModifierKeysFor ( event ) ,
593
604
position : getScreenEventPositionFor ( event ) ,
605
+ deviceType : getDeviceTypeFor ( event ) ,
594
606
} ;
595
607
596
608
if ( model . moveTimeoutID === 0 ) {
@@ -660,6 +672,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
660
672
...normalizeWheel ( event ) ,
661
673
...getModifierKeysFor ( event ) ,
662
674
position : getScreenEventPositionFor ( event ) ,
675
+ deviceType : getDeviceTypeFor ( event ) ,
663
676
} ;
664
677
665
678
if ( model . wheelTimeoutID === 0 ) {
@@ -681,6 +694,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
681
694
const callData = {
682
695
...getModifierKeysFor ( event ) ,
683
696
position : getScreenEventPositionFor ( event ) ,
697
+ deviceType : getDeviceTypeFor ( event ) ,
684
698
} ;
685
699
switch ( event . button ) {
686
700
case 0 :
@@ -708,6 +722,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
708
722
const callData = {
709
723
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
710
724
position : pointers [ 0 ] . position ,
725
+ deviceType : getDeviceTypeFor ( event ) ,
711
726
} ;
712
727
publicAPI . leftButtonReleaseEvent ( callData ) ;
713
728
}
@@ -717,12 +732,13 @@ function vtkRenderWindowInteractor(publicAPI, model) {
717
732
const callData = {
718
733
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
719
734
position : getScreenEventPositionFor ( event ) ,
735
+ deviceType : getDeviceTypeFor ( event ) ,
720
736
} ;
721
737
publicAPI . leftButtonPressEvent ( callData ) ;
722
738
}
723
739
} ;
724
740
725
- publicAPI . handleTouchMove = ( ) => {
741
+ publicAPI . handleTouchMove = ( event ) => {
726
742
const pointers = [ ...pointerCache . values ( ) ] ;
727
743
if ( model . recognizeGestures && pointers . length > 1 ) {
728
744
const positions = pointerCacheToPositions ( pointerCache ) ;
@@ -731,12 +747,13 @@ function vtkRenderWindowInteractor(publicAPI, model) {
731
747
const callData = {
732
748
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
733
749
position : pointers [ 0 ] . position ,
750
+ deviceType : getDeviceTypeFor ( event ) ,
734
751
} ;
735
752
publicAPI . mouseMoveEvent ( callData ) ;
736
753
}
737
754
} ;
738
755
739
- publicAPI . handleTouchEnd = ( ) => {
756
+ publicAPI . handleTouchEnd = ( event ) => {
740
757
const pointers = [ ...pointerCache . values ( ) ] ;
741
758
742
759
if ( model . recognizeGestures ) {
@@ -745,6 +762,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
745
762
const callData = {
746
763
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
747
764
position : pointers [ 0 ] . position ,
765
+ deviceType : getDeviceTypeFor ( event ) ,
748
766
} ;
749
767
publicAPI . leftButtonReleaseEvent ( callData ) ;
750
768
} else if ( pointers . length === 1 ) {
@@ -754,6 +772,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
754
772
const callData = {
755
773
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
756
774
position : pointers [ 0 ] . position ,
775
+ deviceType : getDeviceTypeFor ( event ) ,
757
776
} ;
758
777
publicAPI . leftButtonPressEvent ( callData ) ;
759
778
} else {
@@ -765,6 +784,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
765
784
const callData = {
766
785
...getModifierKeysFor ( EMPTY_MOUSE_EVENT ) ,
767
786
position : pointers [ 0 ] . position ,
787
+ deviceType : getDeviceTypeFor ( event ) ,
768
788
} ;
769
789
publicAPI . leftButtonReleaseEvent ( callData ) ;
770
790
}
0 commit comments