forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventMonitorView.m
82 lines (71 loc) · 2.43 KB
/
EventMonitorView.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
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
//
// EventMonitorView.m
// iTerm
//
// Created by George Nachman on 11/9/11.
// Copyright (c) 2011 George Nachman. All rights reserved.
//
#import "EventMonitorView.h"
#import "PointerPrefsController.h"
#import "FutureMethods.h"
#import "iTermApplicationDelegate.h"
@implementation EventMonitorView
- (void)awakeFromNib
{
[self futureSetAcceptsTouchEvents:YES];
[self futureSetWantsRestingTouches:YES];
}
- (void)touchesBeganWithEvent:(NSEvent *)ev
{
numTouches_ = [[ev futureTouchesMatchingPhase:1 | (1 << 2)/*NSTouchPhasesBegan | NSTouchPhasesStationary*/
inView:self] count];
DLog(@"EventMonitorView touchesBeganWithEvent:%@; numTouches=%d", ev, numTouches_);
}
- (void)touchesEndedWithEvent:(NSEvent *)ev
{
numTouches_ = [[ev futureTouchesMatchingPhase:(1 << 2)/*NSTouchPhasesStationary*/
inView:self] count];
DLog(@"EventMonitorView touchesEndedWithEvent:%@; numTouches=%d", ev, numTouches_);
}
- (void)showNotSupported
{
[label_ setStringValue:@"You can't customize that button"];
[label_ performSelector:@selector(setStringValue:) withObject:@"Click or Tap Here to Set Input Fields" afterDelay:1];
}
- (void)mouseUp:(NSEvent *)theEvent
{
DLog(@"EventMonitorView mouseUp:%@", theEvent);
if (numTouches_ == 3) {
[pointerPrefs_ setGesture:kThreeFingerClickGesture
modifiers:[theEvent modifierFlags]];
} else {
[self showNotSupported];
}
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
DLog(@"EventMonitorView rightMouseUp:%@", theEvent);
int buttonNumber = 1;
int clickCount = [theEvent clickCount];
int modMask = [theEvent modifierFlags];
[pointerPrefs_ setButtonNumber:buttonNumber clickCount:clickCount modifiers:modMask];
[super mouseDown:theEvent];
}
- (void)otherMouseDown:(NSEvent *)theEvent
{
DLog(@"EventMonitorView otherMouseDown:%@", theEvent);
int buttonNumber = [theEvent buttonNumber];
int clickCount = [theEvent clickCount];
int modMask = [theEvent modifierFlags];
[pointerPrefs_ setButtonNumber:buttonNumber clickCount:clickCount modifiers:modMask];
[super mouseDown:theEvent];
}
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor whiteColor] set];
NSRectFill(dirtyRect);
[[NSColor blackColor] set];
NSFrameRect(NSMakeRect(0, 0, self.frame.size.width, self.frame.size.height));
[super drawRect:dirtyRect];
}
@end