mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-03 00:06:31 +00:00
Fix conflicting touch action handling on UIAppView and UIComputerView
This commit is contained in:
parent
f5e0443abb
commit
60a6582380
@ -46,15 +46,19 @@ static UIImage* noImage;
|
|||||||
[_appImage setImage:noImage];
|
[_appImage setImage:noImage];
|
||||||
[self addSubview:_appImage];
|
[self addSubview:_appImage];
|
||||||
|
|
||||||
|
// Use UIContextMenuInteraction on iOS 13.0+ and a standard UILongPressGestureRecognizer
|
||||||
|
// for tvOS devices and iOS prior to 13.0.
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
if (@available(iOS 13.0, *)) {
|
if (@available(iOS 13.0, *)) {
|
||||||
UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self];
|
UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self];
|
||||||
[self addInteraction:rightClickInteraction];
|
[self addInteraction:rightClickInteraction];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(appLongClicked:)];
|
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(appLongClicked:)];
|
||||||
[self addGestureRecognizer:longPressRecognizer];
|
[self addGestureRecognizer:longPressRecognizer];
|
||||||
|
}
|
||||||
|
|
||||||
[self addTarget:self action:@selector(appClicked:) forControlEvents:UIControlEventPrimaryActionTriggered];
|
[self addTarget:self action:@selector(appClicked:) forControlEvents:UIControlEventPrimaryActionTriggered];
|
||||||
|
|
||||||
@ -92,13 +96,6 @@ static UIImage* noImage;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) appLongClicked:(UILongPressGestureRecognizer*)gesture {
|
- (void) appLongClicked:(UILongPressGestureRecognizer*)gesture {
|
||||||
#if !TARGET_OS_TV
|
|
||||||
if (@available(iOS 13.0, *)) {
|
|
||||||
// contextMenuInteraction will handle this
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gesture.state == UIGestureRecognizerStateBegan) {
|
if (gesture.state == UIGestureRecognizerStateBegan) {
|
||||||
[_callback appLongClicked:_app view:self];
|
[_callback appLongClicked:_app view:self];
|
||||||
}
|
}
|
||||||
@ -107,6 +104,11 @@ static UIImage* noImage;
|
|||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
||||||
configurationForMenuAtLocation:(CGPoint)location {
|
configurationForMenuAtLocation:(CGPoint)location {
|
||||||
|
// We don't want to trigger the primary action at this point, so cancel
|
||||||
|
// tracking touch on this view now. This will also have the (intended)
|
||||||
|
// effect of removing the touch highlight on this view.
|
||||||
|
[self cancelTrackingWithEvent:nil];
|
||||||
|
|
||||||
[_callback appLongClicked:_app view:self];
|
[_callback appLongClicked:_app view:self];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -119,15 +119,19 @@ static const int LABEL_DY = 20;
|
|||||||
_host = host;
|
_host = host;
|
||||||
_callback = callback;
|
_callback = callback;
|
||||||
|
|
||||||
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hostLongClicked:)];
|
// Use UIContextMenuInteraction on iOS 13.0+ and a standard UILongPressGestureRecognizer
|
||||||
[self addGestureRecognizer:longPressRecognizer];
|
// for tvOS devices and iOS prior to 13.0.
|
||||||
|
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
if (@available(iOS 13.0, *)) {
|
if (@available(iOS 13.0, *)) {
|
||||||
UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self];
|
UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self];
|
||||||
[self addInteraction:rightClickInteraction];
|
[self addInteraction:rightClickInteraction];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hostLongClicked:)];
|
||||||
|
[self addGestureRecognizer:longPressRecognizer];
|
||||||
|
}
|
||||||
|
|
||||||
[self addTarget:self action:@selector(hostClicked) forControlEvents:UIControlEventPrimaryActionTriggered];
|
[self addTarget:self action:@selector(hostClicked) forControlEvents:UIControlEventPrimaryActionTriggered];
|
||||||
|
|
||||||
@ -206,13 +210,6 @@ static const int LABEL_DY = 20;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) hostLongClicked:(UILongPressGestureRecognizer*)gesture {
|
- (void) hostLongClicked:(UILongPressGestureRecognizer*)gesture {
|
||||||
#if !TARGET_OS_TV
|
|
||||||
if (@available(iOS 13.0, *)) {
|
|
||||||
// contextMenuInteraction will handle this
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gesture.state == UIGestureRecognizerStateBegan) {
|
if (gesture.state == UIGestureRecognizerStateBegan) {
|
||||||
[_callback hostLongClicked:_host view:self];
|
[_callback hostLongClicked:_host view:self];
|
||||||
}
|
}
|
||||||
@ -221,6 +218,11 @@ static const int LABEL_DY = 20;
|
|||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction
|
||||||
configurationForMenuAtLocation:(CGPoint)location {
|
configurationForMenuAtLocation:(CGPoint)location {
|
||||||
|
// We don't want to trigger the primary action at this point, so cancel
|
||||||
|
// tracking touch on this view now. This will also have the (intended)
|
||||||
|
// effect of removing the touch highlight on this view.
|
||||||
|
[self cancelTrackingWithEvent:nil];
|
||||||
|
|
||||||
[_callback hostLongClicked:_host view:self];
|
[_callback hostLongClicked:_host view:self];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user