Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 77 lines (65 sloc) 2.103 kB
afbb961 @gnachman Add event monitor, fix some bugs.
authored
1 //
2 // EventMonitorView.m
3 // iTerm
4 //
5 // Created by George Nachman on 11/9/11.
dfc7fce @gnachman Fix up copyright messages
authored
6 // Copyright (c) 2011 George Nachman. All rights reserved.
afbb961 @gnachman Add event monitor, fix some bugs.
authored
7 //
8
9 #import "EventMonitorView.h"
10 #import "PointerPrefsController.h"
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
11 #import "FutureMethods.h"
afbb961 @gnachman Add event monitor, fix some bugs.
authored
12
13 @implementation EventMonitorView
14
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
15 - (void)awakeFromNib
16 {
17 [self futureSetAcceptsTouchEvents:YES];
18 [self futureSetWantsRestingTouches:YES];
19 }
20
21 - (void)touchesBeganWithEvent:(NSEvent *)ev
22 {
23 numTouches_ = [[ev futureTouchesMatchingPhase:1 | (1 << 2)/*NSTouchPhasesBegan | NSTouchPhasesStationary*/
24 inView:self] count];
25 }
26
27 - (void)touchesEndedWithEvent:(NSEvent *)ev
28 {
29 numTouches_ = [[ev futureTouchesMatchingPhase:(1 << 2)/*NSTouchPhasesStationary*/
30 inView:self] count];
31 }
32
afbb961 @gnachman Add event monitor, fix some bugs.
authored
33 - (void)showNotSupported
34 {
35 [label_ setStringValue:@"You can't customize that button"];
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
36 [label_ performSelector:@selector(setStringValue:) withObject:@"Click or Tap Here to Set Input Fields" afterDelay:1];
afbb961 @gnachman Add event monitor, fix some bugs.
authored
37 }
38
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
39 - (void)mouseUp:(NSEvent *)theEvent
afbb961 @gnachman Add event monitor, fix some bugs.
authored
40 {
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
41 if (numTouches_ == 3) {
42 [pointerPrefs_ setGesture:kThreeFingerClickGesture
43 modifiers:[theEvent modifierFlags]];
44 } else {
45 [self showNotSupported];
46 }
afbb961 @gnachman Add event monitor, fix some bugs.
authored
47 }
48
810371e @gnachman Hook up set defaults button in pointer prefs. Add support for tapping…
authored
49 - (void)rightMouseUp:(NSEvent *)theEvent
afbb961 @gnachman Add event monitor, fix some bugs.
authored
50 {
694ce36 @gnachman Make right mouse button configurable.
authored
51 int buttonNumber = 1;
52 int clickCount = [theEvent clickCount];
53 int modMask = [theEvent modifierFlags];
54 [pointerPrefs_ setButtonNumber:buttonNumber clickCount:clickCount modifiers:modMask];
55 [super mouseDown:theEvent];
afbb961 @gnachman Add event monitor, fix some bugs.
authored
56 }
57
58 - (void)otherMouseDown:(NSEvent *)theEvent
59 {
60 int buttonNumber = [theEvent buttonNumber];
61 int clickCount = [theEvent clickCount];
62 int modMask = [theEvent modifierFlags];
63 [pointerPrefs_ setButtonNumber:buttonNumber clickCount:clickCount modifiers:modMask];
64 [super mouseDown:theEvent];
65 }
66
67 - (void)drawRect:(NSRect)dirtyRect
68 {
69 [[NSColor whiteColor] set];
70 NSRectFill(dirtyRect);
71 [[NSColor blackColor] set];
72 NSFrameRect(NSMakeRect(0, 0, self.frame.size.width, self.frame.size.height));
73
74 [super drawRect:dirtyRect];
75 }
76 @end
Something went wrong with that request. Please try again.