@@ -986,8 +986,6 @@ void CompositionEventHandler::UpdateActiveTouch(
986986 // activeTouch.touch.shiftKey = false;
987987 // activeTouch.touch.ctrlKey = false;
988988 // activeTouch.touch.altKey = false;
989-
990- // activeTouch.touch.isPrimary = true;
991989}
992990
993991facebook::react::PointerEvent CreatePointerEventFromIncompleteHoverData (
@@ -1246,15 +1244,15 @@ void CompositionEventHandler::onPointerPressed(
12461244 ->eventEmitterAtPoint (ptLocal)) {
12471245 activeTouch.eventEmitter = eventEmitter;
12481246 activeTouch.touch .target = targetComponentView.Tag ();
1249- // activeTouch.componentView = componentView ;
1247+ activeTouch.initialComponentView = targetComponentView ;
12501248 break ;
12511249 }
12521250 targetComponentView = targetComponentView.Parent ();
12531251 }
12541252
12551253 UpdateActiveTouch (activeTouch, ptScaled, ptLocal);
12561254
1257- // activeTouch.touch. isPrimary = true ;
1255+ activeTouch.isPrimary = pointerId == 1 ;
12581256 activeTouch.touch .identifier = pointerId;
12591257
12601258 // If the pointer has not been marked as hovering over views before the touch started, we register
@@ -1459,11 +1457,26 @@ facebook::react::PointerEvent CompositionEventHandler::CreatePointerEventFromAct
14591457
14601458 // event.tangentialPressure = 0.0;
14611459 // event.twist = 0;
1462- // event.isPrimary = activeTouch.isPrimary;
1460+ event.isPrimary = activeTouch.isPrimary ;
14631461
14641462 return event;
14651463}
14661464
1465+ bool CompositionEventHandler::IsPointerWithinInitialTree (const ActiveTouch &activeTouch) noexcept {
1466+ auto initialComponentView = activeTouch.initialComponentView .view ();
1467+ if (!initialComponentView)
1468+ return false ;
1469+
1470+ auto initialViewSet = GetTouchableViewsInPathToRoot (initialComponentView);
1471+
1472+ for (const auto &view : initialViewSet) {
1473+ if (view.Tag () == activeTouch.touch .target )
1474+ return true ;
1475+ }
1476+
1477+ return false ;
1478+ }
1479+
14671480// If we have events that include multiple pointer updates, we should change arg from pointerId to vector<pointerId>
14681481void CompositionEventHandler::DispatchTouchEvent (
14691482 TouchEventType eventType,
@@ -1520,6 +1533,13 @@ void CompositionEventHandler::DispatchTouchEvent(
15201533 }
15211534 case TouchEventType::End:
15221535 activeTouch.eventEmitter ->onPointerUp (pointerEvent);
1536+ if (pointerEvent.isPrimary && pointerEvent.button == 0 ) {
1537+ if (IsPointerWithinInitialTree (activeTouch)) {
1538+ activeTouch.eventEmitter ->onClick (pointerEvent);
1539+ }
1540+ } /* else if (IsPointerWithinInitialTree(activeTouch)) {
1541+ activeTouch.eventEmitter->onAuxClick(pointerEvent);
1542+ } */
15231543 break ;
15241544 case TouchEventType::Cancel:
15251545 case TouchEventType::CaptureLost:
0 commit comments