-
Notifications
You must be signed in to change notification settings - Fork 3
/
IPDFRightClickInteraction.m
41 lines (32 loc) · 1.14 KB
/
IPDFRightClickInteraction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// IPDFRightClickInteraction.m
// InstaPDF for Mac
//
// Created by mmackh on 13.10.19.
// Copyright © 2019 mackh ag. All rights reserved.
//
#import "IPDFRightClickInteraction.h"
@interface IPDFRightClickInteraction () <UIContextMenuInteractionDelegate>
@property (nonatomic,copy) void(^rightClickHandler)(void);
@end
@implementation IPDFRightClickInteraction
+ (instancetype)interactionForParentView:(UIView *)parentView rightClickHandler:(void(^)(void))rightClickHandler
{
IPDFRightClickInteraction *clickInteraction = [[self class] interaction];
[parentView addInteraction:clickInteraction];
clickInteraction.rightClickHandler = rightClickHandler;
return clickInteraction;
}
+ (instancetype)interaction
{
id delegate = nil;
IPDFRightClickInteraction *interaction = [[[self class] alloc] initWithDelegate:delegate];
[interaction setValue:interaction forKey:@"delegate"];
return interaction;
}
- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction configurationForMenuAtLocation:(CGPoint)location
{
if (self.rightClickHandler) self.rightClickHandler();
return nil;
}
@end