-
Notifications
You must be signed in to change notification settings - Fork 3
/
IPDFMacEventBus.h
102 lines (69 loc) · 2.08 KB
/
IPDFMacEventBus.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// IPDFMacEventBus.h
// InstaPDF for Mac
//
// Created by mmackh on 18.10.19.
// Copyright © 2019 mackh ag. All rights reserved.
//
#import <Foundation/Foundation.h>
#if TARGET_OS_MACCATALYST
NS_ASSUME_NONNULL_BEGIN
typedef NS_OPTIONS(NSUInteger, IPDFMacEventBusType)
{
IPDFMacEventBusTypeUnknown = 0,
IPDFMacEventBusTypeKeydown = 1ULL << 10,
IPDFMacEventBusTypeKeyup = 1ULL << 11,
IPDFMacEventBusTypeFlagsChanged = 1ULL << 12,
IPDFMacEventBusTypeSwipe = 1ULL << 31,
IPDFMacEventBusTypeAppState = 1ULL << 1000,
};
typedef NS_ENUM(NSInteger, IPDFMacEventBusAppStateEvent)
{
IPDFMacEventBusAppStateEventHide,
IPDFMacEventBusAppStateEventUnhide,
IPDFMacEventBusAppStateEventBecomeActive,
IPDFMacEventBusAppStateEventResignActive,
IPDFMacEventBusAppStateEventTerminate,
IPDFMacEventBusAppStateEventScreenParameters,
};
@class IPDFMacEventBusMonitor;
@class IPDFMacEventBusEvent;
@interface IPDFMacEventBus : NSObject
+ (instancetype)sharedBus;
+ (IPDFMacEventBusEvent *)currentEvent;
- (void)addMonitor:(IPDFMacEventBusMonitor *)monitor;
- (void)removeMonitor:(IPDFMacEventBusMonitor *)monitor;
@end
@interface IPDFMacEventBusMonitor : NSObject
+ (instancetype)monitorWithType:(IPDFMacEventBusType)type eventHandler:(IPDFMacEventBusEvent * _Nullable (^)(IPDFMacEventBusEvent * event))eventHandler;
@property (nonatomic,assign) BOOL enabled;
@end
@interface IPDFMacEventBusEvent : NSObject
@property (nonatomic,readonly) IPDFMacEventBusType type;
@property (nonatomic,readonly) id underlyingEvent;
@end
@interface IPDFMacEventBusEvent (Keyboard)
- (NSString *)characters;
- (NSInteger)keyCode;
- (BOOL)isTab;
- (BOOL)isEnter;
- (BOOL)isESC;
- (BOOL)isArrowKey;
- (BOOL)isArrowUp;
- (BOOL)isArrowDown;
- (BOOL)isArrowRight;
- (BOOL)isArrowLeft;
- (BOOL)ctrlModifier;
- (BOOL)cmdModifier;
- (BOOL)shiftModifier;
- (BOOL)optionModifier;
@end
@interface IPDFMacEventBusEvent (Swipe)
- (CGFloat)deltaX;
- (CGFloat)deltaY;
@end
@interface IPDFMacEventBusEvent (AppState)
- (IPDFMacEventBusAppStateEvent)appState;
@end
NS_ASSUME_NONNULL_END
#endif