forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFutureMethods.m
55 lines (51 loc) · 1.85 KB
/
FutureMethods.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// FutureMethods.m
// iTerm
//
// Created by George Nachman on 8/29/11.
// Copyright 2011 Georgetech. All rights reserved.
//
#import "FutureMethods.h"
@implementation NSView (Future)
- (void)futureSetAcceptsTouchEvents:(BOOL)value
{
if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(setAcceptsTouchEvents:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(setAcceptsTouchEvents:)];
[inv setArgument:&value atIndex:2];
[inv invoke];
}
}
- (void)futureSetWantsRestingTouches:(BOOL)value
{
if ([self respondsToSelector:@selector(setWantsRestingTouches:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(setWantsRestingTouches:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(setWantsRestingTouches:)];
[inv setArgument:&value atIndex:2];
[inv invoke];
}
}
@end
@implementation NSEvent (Future)
- (NSArray *)futureTouchesMatchingPhase:(int)phase inView:(NSView *)view
{
if ([self respondsToSelector:@selector(touchesMatchingPhase:inView:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(touchesMatchingPhase:inView:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(touchesMatchingPhase:inView:)];
[inv setArgument:&phase atIndex:2];
[inv setArgument:&view atIndex:3];
[inv invoke];
NSArray *result;
[inv getReturnValue:&result];
return result;
} else {
return [NSArray array];
}
}
@end