-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUIResponder.j
151 lines (105 loc) · 3.87 KB
/
UIResponder.j
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* UIResponder.j
* UIKit
*
* Created by Amari Robinson.
* Copyright 2011, Amari Robinson.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
// This is the root of the responder tree.
var UIRootResponder = nil;
@implementation UIResponder : CPResponder { // Unsure whether it should be its own class, directly derived from CPObject
UIResponder _nextResponder @accessors(getter=nextResponder; setter=setNextResponder:);
BOOL _isFirstResponder;
UIView _inputView @accessors(inputView);
UIView _inputAccessoryView @accessors(getter=inputAccessoryView);
UIUndoManager _undoManager @accessors(getter=undoManager);
DOMElement _DOMElement;
}
- (id)init {
if (self = [super init]) {
// This property is typically used to replace the system-supplied keyboard that is presented for UITextField and UITextView objects.
_inputView = nil;
//This property is typically used to attach an accessory view to the system-supplied keyboard that is presented for UITextField and UITextView objects.
_inputAccessoryView = nil;
}
return self;
}
- (void)touchstartDOMEvent:(JSObject)evt {
evt.preventDefault();
var touches = evt.changedTouches.map(function (x) { return [UITouch touchWithJSTouch:x]; });
[self touchesBegan:[CPSet setWithArray:touches] withEvent:[UIEvent eventWithJSEvent:evt]];
}
- (void)touchmoveDOMEvent:(JSObject)evt {
evt.preventDefault();
var touches = evt.changedTouches.map(function (x) { return [UITouch touchWithJSTouch:x]; });
[self touchesEnded:[CPSet setWithArray:touches] withEvent:[UIEvent eventWithJSEvent:evt]];
}
- (void)touchendDOMEvent:(JSObject)evt {
evt.preventDefault();
var touches = evt.changedTouches.map(function (x) { return [UITouch touchWithJSTouch:x]; });
[self touchesMoved:[CPSet setWithArray:touches] withEvent:[UIEvent eventWithJSEvent:evt]];
}
- (void)touchcancelDOMEvent:(JSObject)evt {
evt.preventDefault();
var touches = evt.changedTouches.map(function (x) { return [UITouch touchWithJSTouch:x]; });
[self touchesCanceled:[CPSet setWithArray:touches] withEvent:[UIEvent eventWithJSEvent:evt]];
}
- (BOOL)isFirstResponder {
return NO;
}
- (BOOL)canBecomeFirstResponder {
return NO;
}
- (BOOL)becomeFirstResponder {
return YES;
}
- (BOOL)canResignFirstResponder {
return YES;
}
- (BOOL)resignFirstResponder {
return YES;
}
/* Managing Input Views */
- (void)reloadInputViews {
}
/* Responding to Touch Events */
- (void)touchesBegan:(CPSet)touches withEvent:(UIEvent)event {
}
- (void)touchesMoved:(CPSet)touches withEvent:(UIEvent)event {
}
- (void)touchesEnded:(CPSet)touches withEvent:(UIEvent)event {
}
- (void)touchesCancelled:(CPSet)touches withEvent:(UIEvent)event {
}
/* Responding to Motion Events */
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
/* */
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
}
/* Validating Commands */
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (!_nextResponder)
return NO;
return [_nextResponder canPerformAction:action withSender:sender];
}
@end