-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.xm
70 lines (59 loc) · 1.58 KB
/
Tweak.xm
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
#import <UIKit/UIKit2.h>
NSString* key;
static BOOL isReturnKey = NO;
NSTimer* timerForReturn;
%hook UIKeyboardLayoutStar
- (void)longPressAction
{
if(isReturnKey && ![timerForReturn isValid])timerForReturn = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(returnKeyLongPress) userInfo:nil repeats:NO];
%orig;
}
%new
- (void)returnKeyLongPress
{
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
if (timerForReturn != nil)
[timerForReturn invalidate];
timerForReturn = nil;
isReturnKey = NO;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
key = [[[self keyHitTest:[touch locationInView:touch.view]] name] lowercaseString];
if ([key isEqualToString:@"return-key"]) {
isReturnKey = YES;
}
else {
isReturnKey = NO;
}
%orig;
}
-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
if (timerForReturn != nil)
[timerForReturn invalidate];
timerForReturn = nil;
isReturnKey = NO;
%orig;
}
-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [touches anyObject];
key = [[[self keyHitTest:[touch locationInView:touch.view]] name] lowercaseString];
if ([key isEqualToString:@"return-key"]) {
isReturnKey = YES;
}else{
if (timerForReturn != nil) {
[timerForReturn invalidate];
timerForReturn = nil;
}
isReturnKey = NO;
}
%orig;
}
-(void)touchesCanceled:(NSSet*)touches withEvent:(UIEvent*)event {
if (timerForReturn != nil)
[timerForReturn invalidate];
timerForReturn = nil;
isReturnKey = NO;
%orig;
}
%end