diff --git a/Limelight/UIAppView.h b/Limelight/UIAppView.h index 89ee83e..9f2504c 100644 --- a/Limelight/UIAppView.h +++ b/Limelight/UIAppView.h @@ -16,7 +16,11 @@ @end +#if !TARGET_OS_TV +@interface UIAppView : UIButton +#else @interface UIAppView : UIButton +#endif - (id) initWithApp:(TemporaryApp*)app cache:(NSCache*)cache andCallback:(id)callback; - (void) updateAppImage; diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index 822269b..40ecc1a 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -46,6 +46,13 @@ static UIImage* noImage; [_appImage setImage:noImage]; [self addSubview:_appImage]; +#if !TARGET_OS_TV + if (@available(iOS 13.0, *)) { + UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self]; + [self addInteraction:rightClickInteraction]; + } +#endif + UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(appLongClicked:)]; [self addGestureRecognizer:longPressRecognizer]; @@ -79,11 +86,26 @@ static UIImage* noImage; } - (void) appLongClicked:(UILongPressGestureRecognizer*)gesture { +#if !TARGET_OS_TV + if (@available(iOS 13.0, *)) { + // contextMenuInteraction will handle this + return; + } +#endif + if (gesture.state == UIGestureRecognizerStateBegan) { [_callback appLongClicked:_app view:self]; } } +#if !TARGET_OS_TV +- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction + configurationForMenuAtLocation:(CGPoint)location { + [_callback appLongClicked:_app view:self]; + return nil; +} +#endif + - (void) updateAppImage { if (_appOverlay != nil) { [_appOverlay removeFromSuperview]; diff --git a/Limelight/UIComputerView.h b/Limelight/UIComputerView.h index e96d072..911c699 100644 --- a/Limelight/UIComputerView.h +++ b/Limelight/UIComputerView.h @@ -17,7 +17,11 @@ @end +#if !TARGET_OS_TV +@interface UIComputerView : UIButton +#else @interface UIComputerView : UIButton +#endif - (id) initWithComputer:(TemporaryHost*)host andCallback:(id)callback; - (id) initForAddWithCallback:(id)callback; diff --git a/Limelight/UIComputerView.m b/Limelight/UIComputerView.m index 143811c..f9ff80d 100644 --- a/Limelight/UIComputerView.m +++ b/Limelight/UIComputerView.m @@ -122,6 +122,13 @@ static const int LABEL_DY = 20; UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hostLongClicked:)]; [self addGestureRecognizer:longPressRecognizer]; +#if !TARGET_OS_TV + if (@available(iOS 13.0, *)) { + UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self]; + [self addInteraction:rightClickInteraction]; + } +#endif + [self addTarget:self action:@selector(hostClicked) forControlEvents:UIControlEventPrimaryActionTriggered]; [self updateContentsForHost:host]; @@ -194,11 +201,26 @@ static const int LABEL_DY = 20; } - (void) hostLongClicked:(UILongPressGestureRecognizer*)gesture { +#if !TARGET_OS_TV + if (@available(iOS 13.0, *)) { + // contextMenuInteraction will handle this + return; + } +#endif + if (gesture.state == UIGestureRecognizerStateBegan) { [_callback hostLongClicked:_host view:self]; } } +#if !TARGET_OS_TV +- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction + configurationForMenuAtLocation:(CGPoint)location { + [_callback hostLongClicked:_host view:self]; + return nil; +} +#endif + - (void) hostClicked { [_callback hostClicked:_host view:self]; }