Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pointerType to event #2760

Merged
merged 32 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
880b134
Basic iOS implementation
m-bert Feb 16, 2024
9722fda
Add flag to Info.plist
m-bert Feb 16, 2024
05fd2d3
Add PointerType enum
m-bert Feb 16, 2024
5ef00c7
Add pointerType on Web
m-bert Feb 16, 2024
74d76dd
Add android implementation
m-bert Feb 16, 2024
16e5ccb
Fix macOS
m-bert Feb 16, 2024
baeac06
Add pointerType to GestureEventPayload
m-bert Feb 16, 2024
2013287
Add pointerType export to index
m-bert Feb 19, 2024
30c14e1
Add example
m-bert Feb 19, 2024
7c44264
Fix iOS build
m-bert Feb 19, 2024
5200224
Add runOnJS to example
m-bert Feb 19, 2024
7bf1e55
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 19, 2024
aa6830d
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 19, 2024
4695e7b
Fix type
m-bert Feb 19, 2024
66c87ff
Change cocoapods version
m-bert Feb 19, 2024
bc7dcfd
Fix format in yaml
m-bert Feb 19, 2024
098f194
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 19, 2024
407bbbe
Remove WebPointerType interface
m-bert Feb 20, 2024
adbdf3c
Change setCurrentPointer name on macOS
m-bert Feb 20, 2024
846cfbf
Remove imports
m-bert Feb 20, 2024
711becb
Set pointerType in NativeViewGestureHandler
m-bert Feb 20, 2024
ad7cbc0
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 20, 2024
fd4fe73
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 20, 2024
7e67f7b
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 20, 2024
ff9ad8c
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 21, 2024
f6b1ca5
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 21, 2024
316e70b
Merge branch 'main' into @mbert/add-pointertype-to-event
m-bert Feb 22, 2024
025f549
Change FINGER to TOUCH on android
m-bert Feb 27, 2024
f74ce39
Change FINGER to TOUCH on web
m-bert Feb 27, 2024
ab677e2
Remove unnecessary setCurrentPointerType in NativeViewGestureHandler …
m-bert Feb 27, 2024
6a92b89
Change Pen to Stylus in PointerEventManager
m-bert Feb 27, 2024
77ab5ce
Remove setting pointerType in handleDragEnter
m-bert Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
with:
node-version: 18
cache: 'yarn'
- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.15.2
m-bert marked this conversation as resolved.
Show resolved Hide resolved
- name: Install node dependencies
working-directory: ${{ matrix.working-directory }}
run: yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
protected var orchestrator: GestureHandlerOrchestrator? = null
private var onTouchEventListener: OnTouchEventListener? = null
private var interactionController: GestureHandlerInteractionController? = null
var pointerType: Int = POINTER_TYPE_OTHER
private set

@Suppress("UNCHECKED_CAST")
protected fun self(): ConcreteGestureHandlerT = this as ConcreteGestureHandlerT
Expand Down Expand Up @@ -371,6 +373,11 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
lastAbsolutePositionY = GestureUtils.getLastPointerY(adaptedTransformedEvent, true)
lastEventOffsetX = adaptedTransformedEvent.rawX - adaptedTransformedEvent.x
lastEventOffsetY = adaptedTransformedEvent.rawY - adaptedTransformedEvent.y

if (sourceEvent.action == MotionEvent.ACTION_DOWN || sourceEvent.action == MotionEvent.ACTION_HOVER_ENTER || sourceEvent.action == MotionEvent.ACTION_HOVER_MOVE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(just for clarification) I assume there is no need to set type of pointer on MotionEvent.ACTION_HOVER_EXIT right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't think we need to set that on exit. The main idea was to set this variable when gesture receives first event (inside onPointerDown on web, touchesBegan on iOS, etc.).

Now I see that in NativeViewGestureHandler on iOS i call setCurrentPointerType also on TouchUp methods. I will check if it is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, I've tested that and it seems that we don't need most of those calls. I removed them in ab677e2. I've left one in handleDragEnter since I'm not sure when this method is called. If you know how to test it let me know, I'll be grateful, cc @j-piasecki.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleDragEnter should be called when pointer moves into the view boundary without touching down. I'm not sure whether it requires to start drag inside the view (touch the view -> drag outside -> drag back inside) or not (touch outside the view -> drag into the view)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've just checked that and it does require to start drag inside of view. Given that, I removed the line that sets pointerType inside that function in 77ab5ce.

setPointerType(sourceEvent)
}

if (sourceEvent.action == MotionEvent.ACTION_HOVER_ENTER ||
sourceEvent.action == MotionEvent.ACTION_HOVER_MOVE ||
sourceEvent.action == MotionEvent.ACTION_HOVER_EXIT
Expand Down Expand Up @@ -721,6 +728,17 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
isWithinBounds = false
}

fun setPointerType(event: MotionEvent) {
val pointerIndex = event.actionIndex

pointerType = when (event.getToolType(pointerIndex)) {
MotionEvent.TOOL_TYPE_FINGER -> POINTER_TYPE_FINGER
MotionEvent.TOOL_TYPE_STYLUS -> POINTER_TYPE_STYLUS
MotionEvent.TOOL_TYPE_MOUSE -> POINTER_TYPE_MOUSE
else -> POINTER_TYPE_OTHER
}
}

fun setOnTouchEventListener(listener: OnTouchEventListener?): GestureHandler<*> {
onTouchEventListener = listener
return this
Expand Down Expand Up @@ -763,6 +781,10 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
const val ACTION_TYPE_NATIVE_ANIMATED_EVENT = 2
const val ACTION_TYPE_JS_FUNCTION_OLD_API = 3
const val ACTION_TYPE_JS_FUNCTION_NEW_API = 4
const val POINTER_TYPE_FINGER = 0
const val POINTER_TYPE_STYLUS = 1
const val POINTER_TYPE_MOUSE = 2
const val POINTER_TYPE_OTHER = 3
private const val MAX_POINTERS_COUNT = 12
private lateinit var pointerProps: Array<PointerProperties?>
private lateinit var pointerCoords: Array<PointerCoords?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ abstract class GestureHandlerEventDataBuilder<T : GestureHandler<T>>(handler: T)
private val numberOfPointers: Int
private val handlerTag: Int
private val state: Int
private val pointerType: Int

init {
numberOfPointers = handler.numberOfPointers
handlerTag = handler.tag
state = handler.state
pointerType = handler.pointerType
}

open fun buildEventData(eventData: WritableMap) {
eventData.putInt("numberOfPointers", numberOfPointers)
eventData.putInt("handlerTag", handlerTag)
eventData.putInt("state", state)
eventData.putInt("pointerType", pointerType)
}
}
9 changes: 5 additions & 4 deletions apple/Handlers/RNFlingHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
_lastPoint = [[[touches allObjects] objectAtIndex:0] locationInView:_gestureHandler.recognizer.view];
[_gestureHandler reset];
[super touchesBegan:touches withEvent:event];
Expand Down Expand Up @@ -141,16 +142,16 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(id)_recognizer

RNBetterSwipeGestureRecognizer *recognizer = (RNBetterSwipeGestureRecognizer *)_recognizer;

CGPoint viewAbsolutePosition =
[recognizer.view convertPoint:recognizer.view.bounds.origin
toView:RCTKeyWindow().rootViewController.view];
CGPoint viewAbsolutePosition = [recognizer.view convertPoint:recognizer.view.bounds.origin
toView:RCTKeyWindow().rootViewController.view];
CGPoint locationInView = [recognizer getLastLocation];

return [RNGestureHandlerEventExtraData
forPosition:locationInView
withAbsolutePosition:CGPointMake(
viewAbsolutePosition.x + locationInView.x, viewAbsolutePosition.y + locationInView.y)
withNumberOfTouches:recognizer.numberOfTouches];
withNumberOfTouches:recognizer.numberOfTouches
withPointerType:_pointerType];
}
@end

Expand Down
4 changes: 3 additions & 1 deletion apple/Handlers/RNForceTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
if (_firstTouch) {
// ignore rest of fingers
return;
Expand Down Expand Up @@ -171,7 +172,8 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(RNForceTouchGestureRecognize
return [RNGestureHandlerEventExtraData forForce:recognizer.force
forPosition:[recognizer locationInView:recognizer.view]
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
withNumberOfTouches:recognizer.numberOfTouches];
withNumberOfTouches:recognizer.numberOfTouches
withPointerType:_pointerType];
}

@end
Expand Down
3 changes: 2 additions & 1 deletion apple/Handlers/RNHoverHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ - (void)configure:(NSDictionary *)config
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recognizer
{
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:recognizer.view]
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]];
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
withPointerType:UITouchTypePencil];
m-bert marked this conversation as resolved.
Show resolved Hide resolved
}

@end
Expand Down
4 changes: 3 additions & 1 deletion apple/Handlers/RNLongPressHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ - (CGPoint)translationInView

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[super touchesBegan:touches withEvent:event];
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

Expand Down Expand Up @@ -181,7 +182,8 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recogn
return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:recognizer.view]
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
withNumberOfTouches:recognizer.numberOfTouches
withDuration:[(RNBetterLongPressGestureRecognizer *)recognizer getDuration]];
withDuration:[(RNBetterLongPressGestureRecognizer *)recognizer getDuration]
withPointerType:_pointerType];
}
@end

Expand Down
1 change: 1 addition & 0 deletions apple/Handlers/RNManualHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[super touchesBegan:touches withEvent:event];
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

Expand Down
15 changes: 8 additions & 7 deletions apple/Handlers/RNNativeViewHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];
}

Expand Down Expand Up @@ -148,21 +149,21 @@ - (void)handleTouchDown:(UIView *)sender forEvent:(UIEvent *)event

[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
m-bert marked this conversation as resolved.
Show resolved Hide resolved
}

- (void)handleTouchUpOutside:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
}

- (void)handleTouchUpInside:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
}

- (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
Expand All @@ -173,26 +174,26 @@ - (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
[control cancelTrackingWithEvent:event];
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
} else {
[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
}
}

- (void)handleDragEnter:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withPointerType:_pointerType]];
}

- (void)handleTouchCancel:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateCancelled
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withPointerType:_pointerType]];
}

@end
Expand Down
10 changes: 8 additions & 2 deletions apple/Handlers/RNPanHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "RNPanHandler.h"

#if TARGET_OS_OSX
#import "RNGestureHandlerPointerType.h"
m-bert marked this conversation as resolved.
Show resolved Hide resolved

@interface RNBetterPanGestureRecognizer : NSPanGestureRecognizer
#else
#import <UIKit/UIGestureRecognizerSubclass.h>
Expand Down Expand Up @@ -166,6 +168,7 @@ - (void)interactionsCancelled:(NSSet *)touches withEvent:(UIEvent *)event

- (void)mouseDown:(NSEvent *)event
{
[_gestureHandler setCurrentPointerType];
// super call was moved to interactionsBegan method to keep the
// original order of calls
[self interactionsBegan:[NSSet setWithObject:event] withEvent:event];
Expand All @@ -187,6 +190,7 @@ - (void)mouseUp:(NSEvent *)event

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
// super call was moved to interactionsBegan method to keep the
// original order of calls
[self interactionsBegan:touches withEvent:event];
Expand Down Expand Up @@ -400,7 +404,8 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(NSPanGestureRecognizer *)rec
withAbsolutePosition:[recognizer locationInView:recognizer.view.window.contentView]
withTranslation:[recognizer translationInView:recognizer.view.window.contentView]
withVelocity:[recognizer velocityInView:recognizer.view.window.contentView]
withNumberOfTouches:1];
withNumberOfTouches:1
withPointerType:RNGestureHandlerMouse];
}
#else
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIPanGestureRecognizer *)recognizer
Expand All @@ -409,7 +414,8 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(UIPanGestureRecognizer *)rec
withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
withTranslation:[recognizer translationInView:recognizer.view.window]
withVelocity:[recognizer velocityInView:recognizer.view.window]
withNumberOfTouches:recognizer.numberOfTouches];
withNumberOfTouches:recognizer.numberOfTouches
withPointerType:_pointerType];
}
#endif

Expand Down
9 changes: 7 additions & 2 deletions apple/Handlers/RNPinchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//

#import "RNPinchHandler.h"
#import "RNGestureHandlerPointerType.h"

#if !TARGET_OS_TV

Expand Down Expand Up @@ -82,6 +83,7 @@ - (void)magnifyWithEvent:(NSEvent *)event

switch (self.state) {
case NSGestureRecognizerStateBegan:
[_gestureHandler setCurrentPointerType];
[self interactionsBegan:[NSSet setWithObject:event] withEvent:event];
break;
case NSGestureRecognizerStateChanged:
Expand All @@ -102,6 +104,7 @@ - (void)magnifyWithEvent:(NSEvent *)event
#else
- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[super touchesBegan:touches withEvent:event];
[self interactionsBegan:touches withEvent:event];
}
Expand Down Expand Up @@ -155,15 +158,17 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(NSMagnificationGestureRecogn
return [RNGestureHandlerEventExtraData forPinch:recognizer.magnification
withFocalPoint:[recognizer locationInView:recognizer.view]
withVelocity:((RNBetterPinchRecognizer *)recognizer).velocity
withNumberOfTouches:2];
withNumberOfTouches:2
withPointerType:RNGestureHandlerMouse];
}
#else
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIPinchGestureRecognizer *)recognizer
{
return [RNGestureHandlerEventExtraData forPinch:recognizer.scale
withFocalPoint:[recognizer locationInView:recognizer.view]
withVelocity:recognizer.velocity
withNumberOfTouches:recognizer.numberOfTouches];
withNumberOfTouches:recognizer.numberOfTouches
withPointerType:_pointerType];
}
#endif
#endif // !TARGET_OS_TV
Expand Down
9 changes: 7 additions & 2 deletions apple/Handlers/RNRotationHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "RNRotationHandler.h"
#import "RNGestureHandlerPointerType.h"

#if !TARGET_OS_TV

Expand Down Expand Up @@ -76,6 +77,7 @@ - (void)rotateWithEvent:(NSEvent *)event

switch (self.state) {
case NSGestureRecognizerStateBegan:
[_gestureHandler setCurrentPointerType];
[self interactionsBegan:[NSSet setWithObject:event] withEvent:event];
break;
case NSGestureRecognizerStateChanged:
Expand All @@ -96,6 +98,7 @@ - (void)rotateWithEvent:(NSEvent *)event
#else
- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[super touchesBegan:touches withEvent:event];
[self interactionsBegan:touches withEvent:event];
}
Expand Down Expand Up @@ -149,15 +152,17 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(NSRotationGestureRecognizer
return [RNGestureHandlerEventExtraData forRotation:recognizer.rotation
withAnchorPoint:[recognizer locationInView:recognizer.view]
withVelocity:((RNBetterRotationRecognizer *)recognizer).velocity
withNumberOfTouches:2];
withNumberOfTouches:2
withPointerType:RNGestureHandlerMouse];
}
#else
- (RNGestureHandlerEventExtraData *)eventExtraData:(UIRotationGestureRecognizer *)recognizer
{
return [RNGestureHandlerEventExtraData forRotation:recognizer.rotation
withAnchorPoint:[recognizer locationInView:recognizer.view]
withVelocity:recognizer.velocity
withNumberOfTouches:recognizer.numberOfTouches];
withNumberOfTouches:recognizer.numberOfTouches
withPointerType:_pointerType];
}
#endif
#endif // !TARGET_OS_TV
Expand Down
2 changes: 2 additions & 0 deletions apple/Handlers/RNTapHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ - (void)interactionsCancelled:(NSSet *)touches withEvent:(UIEvent *)event
#if TARGET_OS_OSX
- (void)mouseDown:(NSEvent *)event
{
[_gestureHandler setCurrentPointerType];
[super mouseDown:event];
[self interactionsBegan:[NSSet setWithObject:event] withEvent:event];
}
Expand Down Expand Up @@ -184,6 +185,7 @@ - (void)rightMouseUp:(NSEvent *)event

- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[super touchesBegan:touches withEvent:event];
[self interactionsBegan:touches withEvent:event];
}
Expand Down
8 changes: 8 additions & 0 deletions apple/RNGestureHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
UIGestureRecognizer *_recognizer;
@protected
RNGestureHandlerState _lastState;
@protected
NSInteger _pointerType;
}

+ (nullable RNGestureHandler *)findGestureHandlerByRecognizer:(nonnull UIGestureRecognizer *)recognizer;
Expand Down Expand Up @@ -87,4 +89,10 @@
- (void)sendEvent:(nonnull RNGestureHandlerStateChange *)event;
- (void)sendTouchEventInState:(RNGestureHandlerState)state forViewWithTag:(nonnull NSNumber *)reactTag;

#if !TARGET_OS_OSX
- (void)setCurrentPointerType:(nonnull UIEvent *)event;
#else
- (void)setCurrentPointerType;
m-bert marked this conversation as resolved.
Show resolved Hide resolved
#endif

@end
Loading
Loading