mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-20 23:40:17 +00:00
Enable right-click context menus on iPadOS
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user