-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHotkeyActionRepeat.m
More file actions
48 lines (40 loc) · 986 Bytes
/
HotkeyActionRepeat.m
File metadata and controls
48 lines (40 loc) · 986 Bytes
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
//
// HotkeyActionRepeat.m
// Kimidi
//
#import "HotkeyActionRepeat.h"
@implementation HotkeyActionRepeat
- (void) pressed
{
[super pressed];
// wait 400ms before triggering action repeatedly
timer = [NSTimer scheduledTimerWithTimeInterval:.4
target:self
selector:@selector(startRepeated)
userInfo:NULL
repeats:NO];
}
- (void) released
{
[super released];
if ([timer isValid])
{
[timer invalidate];
timer = nil;
}
}
- (void) startRepeated
{
// repeat action every 100ms
timer = [NSTimer scheduledTimerWithTimeInterval:.1
target:self
selector:@selector(executeRepeated)
userInfo:NULL
repeats:YES];
}
- (void) executeRepeated
{
[super released];
[super execute];
}
@end