My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /AppKit/NSResponder.m
e5277a40a7e8 vs. 2470bd80abf4 Compare: vs.  Format:
Revision 2470bd80abf4
Go to: 
Project members, sign in to write a code review
/AppKit/NSResponder.m   e5277a40a7e8 /AppKit/NSResponder.m   2470bd80abf4
1 /* Copyright (c) 2006 Christopher J. W. Lloyd 1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
2 2
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 4
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 6
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8 8
9 // Original - Christopher Lloyd <cjwl@objc.net> 9 // Original - Christopher Lloyd <cjwl@objc.net>
10 #import <AppKit/NSResponder.h> 10 #import <AppKit/NSResponder.h>
11 #import <AppKit/NSEvent.h> 11 #import <AppKit/NSEvent.h>
12 #import <AppKit/NSKeyBindingManager.h> 12 #import <AppKit/NSKeyBindingManager.h>
13 #import <AppKit/NSKeyBinding.h> 13 #import <AppKit/NSKeyBinding.h>
14 #import <AppKit/NSApplication.h> 14 #import <AppKit/NSApplication.h>
15 #import <AppKit/NSNibKeyedUnarchiver.h> 15 #import <AppKit/NSNibKeyedUnarchiver.h>
16 16
17 @implementation NSResponder 17 @implementation NSResponder
18 18
19 -(void)encodeWithCoder:(NSCoder *)encoder { 19 -(void)encodeWithCoder:(NSCoder *)encoder {
20 } 20 }
21 21
22 -initWithCoder:(NSCoder *)coder { 22 -initWithCoder:(NSCoder *)coder {
23 if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){ 23 if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]){
24 NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; 24 NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder;
25 25
26 //; _nextResponder=[keyed decodeObjectForKey:@"NSNextResponder"]; 26 //; _nextResponder=[keyed decodeObjectForKey:@"NSNextResponder"];
27 } 27 }
28 return self; 28 return self;
29 } 29 }
30 30
31 -(NSResponder *)nextResponder { 31 -(NSResponder *)nextResponder {
32 return _nextResponder; 32 return _nextResponder;
33 } 33 }
34 34
35 -(NSMenu *)menu { 35 -(NSMenu *)menu {
36 NSInvalidAbstractInvocation(); 36 NSInvalidAbstractInvocation();
37 return nil; 37 return nil;
38 } 38 }
39 39
40 -(NSUndoManager *)undoManager { 40 -(NSUndoManager *)undoManager {
41 return [_nextResponder performSelector:_cmd]; 41 return [_nextResponder performSelector:_cmd];
42 } 42 }
43 43
44 -(void)setNextResponder:(NSResponder *)responder { 44 -(void)setNextResponder:(NSResponder *)responder {
45 _nextResponder=responder; 45 _nextResponder=responder;
46 } 46 }
47 47
48 -(void)setMenu:(NSMenu *)menu { 48 -(void)setMenu:(NSMenu *)menu {
49 NSInvalidAbstractInvocation(); 49 NSInvalidAbstractInvocation();
50 } 50 }
51 51
52 -validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { 52 -validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType {
53 NSUnimplementedMethod(); 53 NSUnimplementedMethod();
54 return nil; 54 return nil;
55 } 55 }
56 56
57 -(void)doCommandBySelector:(SEL)selector { 57 -(void)doCommandBySelector:(SEL)selector {
58 //NSLog(@"checking %@...", self); 58 //NSLog(@"checking %@...", self);
59 if([self respondsToSelector:selector]) { 59 if([self respondsToSelector:selector]) {
60 // NSLog(@"...%@ responds to %@", self, NSStringFromSelector(selector)); 60 // NSLog(@"...%@ responds to %@", self, NSStringFromSelector(selector));
61 [self performSelector:selector withObject:nil]; 61 [self performSelector:selector withObject:nil];
62 } 62 }
63 else 63 else
64 [_nextResponder doCommandBySelector:selector]; 64 [_nextResponder doCommandBySelector:selector];
65 } 65 }
66 66
67 -(void)interpretKeyEvents:(NSArray *)events { 67 -(void)interpretKeyEvents:(NSArray *)events {
68 int i,count=[events count]; 68 int i,count=[events count];
69 69
70 for(i=0;i<count;i++){ 70 for(i=0;i<count;i++){
71 NSEvent *event=[events objectAtIndex:i]; 71 NSEvent *event=[events objectAtIndex:i];
72 NSString *string=[event charactersIgnoringModifiers]; 72 NSString *string=[event charactersIgnoringModifiers];
73 NSKeyBinding *keyBinding=[[NSKeyBindingManager defaultKeyBindingManager] keyBindingWithString:string modifierFlags:[event modifierFlags]]; 73 NSKeyBinding *keyBinding=[[NSKeyBindingManager defaultKeyBindingManager] keyBindingWithString:string modifierFlags:[event modifierFlags]];
74 NSArray *selectorNames=[keyBinding selectorNames]; 74 NSArray *selectorNames=[keyBinding selectorNames];
75 75
76 if(selectorNames!=nil){ 76 if(selectorNames!=nil){
77 int i = 0, count = [selectorNames count]; 77 int i = 0, count = [selectorNames count];
78 78
79 for (i = 0; i < count; ++i) { 79 for (i = 0; i < count; ++i) {
80 // NSLog(@"doing %@ for %@", [selectorNames objectAtIndex:i], keyBinding); 80 // NSLog(@"doing %@ for %@", [selectorNames objectAtIndex:i], keyBinding);
81 [self doCommandBySelector:NSSelectorFromString([selectorNames objectAtIndex:i])]; 81 [self doCommandBySelector:NSSelectorFromString([selectorNames objectAtIndex:i])];
82 } 82 }
83 } 83 }
84 else if([self respondsToSelector:@selector(insertText:)]){ 84 else if([self respondsToSelector:@selector(insertText:)]){
85 string=[event characters]; 85 string=[event characters];
86 86
87 if([string length]>0){ // FIX THIS IN APPKIT shouldnt get 0 length 87 if([string length]>0){ // FIX THIS IN APPKIT shouldnt get 0 length
88 88
89 unsigned i,length=[string length]; 89 unsigned i,length=[string length];
90 unichar buffer[length]; 90 unichar buffer[length];
91 91
92 [string getCharacters:buffer]; 92 [string getCharacters:buffer];
93 for(i=0;i<length;i++){ 93 for(i=0;i<length;i++){
94 unichar check=buffer[i]; 94 unichar check=buffer[i];
95 95
96 if(check>=NSUpArrowFunctionKey) 96 if(check>=NSUpArrowFunctionKey)
97 check=' '; 97 check=' ';
98 else if(check<' ') 98 else if(check<' ')
99 check=' '; 99 check=' ';
100 100
101 buffer[i]=check; 101 buffer[i]=check;
102 } 102 }
103 string=[NSString stringWithCharacters:buffer length:length]; 103 string=[NSString stringWithCharacters:buffer length:length];
104 [self insertText:string]; 104 [self insertText:string];
105 } 105 }
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 -(BOOL)performKeyEquivalent:(NSEvent *)event { 110 -(BOOL)performKeyEquivalent:(NSEvent *)event {
111 return NO; 111 return NO;
112 } 112 }
113 113
114 -(BOOL)tryToPerform:(SEL)action with:object { 114 -(BOOL)tryToPerform:(SEL)action with:object {
115 if([self respondsToSelector:action]) 115 if([self respondsToSelector:action])
116 [self performSelector:action withObject:object]; 116 [self performSelector:action withObject:object];
117 117
118 return [_nextResponder tryToPerform:action with:object]; 118 return [_nextResponder tryToPerform:action with:object];
119 } 119 }
120 120
121 -(BOOL)acceptsFirstResponder { 121 -(BOOL)acceptsFirstResponder {
122 return NO; 122 return NO;
123 } 123 }
124 124
125 -(BOOL)becomeFirstResponder { 125 -(BOOL)becomeFirstResponder {
126 return YES; 126 return YES;
127 } 127 }
128 128
129 -(BOOL)resignFirstResponder { 129 -(BOOL)resignFirstResponder {
130 return YES; 130 return YES;
131 } 131 }
132 132
133 -(void)flagsChanged:(NSEvent *)event { 133 -(void)flagsChanged:(NSEvent *)event {
134 [_nextResponder performSelector:_cmd withObject:event]; 134 [_nextResponder performSelector:_cmd withObject:event];
135 } 135 }
136 136
137 -(void)keyUp:(NSEvent *)event { 137 -(void)keyUp:(NSEvent *)event {
138 [_nextResponder performSelector:_cmd withObject:event]; 138 [_nextResponder performSelector:_cmd withObject:event];
139 } 139 }
140 140
141 -(void)keyDown:(NSEvent *)event { 141 -(void)keyDown:(NSEvent *)event {
142 [_nextResponder performSelector:_cmd withObject:event]; 142 [_nextResponder performSelector:_cmd withObject:event];
143 } 143 }
144 144
145 -(void)scrollWheel:(NSEvent *)event { 145 -(void)scrollWheel:(NSEvent *)event {
146 [_nextResponder performSelector:_cmd withObject:event]; 146 [_nextResponder performSelector:_cmd withObject:event];
147 } 147 }
148 148
149 -(void)mouseUp:(NSEvent *)event { 149 -(void)mouseUp:(NSEvent *)event {
150 [_nextResponder performSelector:_cmd withObject:event]; 150 [_nextResponder performSelector:_cmd withObject:event];
151 } 151 }
152 152
153 -(void)mouseDown:(NSEvent *)event { 153 -(void)mouseDown:(NSEvent *)event {
154 [_nextResponder performSelector:_cmd withObject:event]; 154 [_nextResponder performSelector:_cmd withObject:event];
155 } 155 }
156 156
157 -(void)mouseMoved:(NSEvent *)event { 157 -(void)mouseMoved:(NSEvent *)event {
158 [_nextResponder performSelector:_cmd withObject:event]; 158 [_nextResponder performSelector:_cmd withObject:event];
159 } 159 }
160 160
161 -(void)mouseEntered:(NSEvent *)event { 161 -(void)mouseEntered:(NSEvent *)event {
162 [_nextResponder performSelector:_cmd withObject:event]; 162 [_nextResponder performSelector:_cmd withObject:event];
163 } 163 }
164 164
165 -(void)mouseExited:(NSEvent *)event { 165 -(void)mouseExited:(NSEvent *)event {
166 [_nextResponder performSelector:_cmd withObject:event]; 166 [_nextResponder performSelector:_cmd withObject:event];
167 } 167 }
168 168
169 -(void)mouseDragged:(NSEvent *)event { 169 -(void)mouseDragged:(NSEvent *)event {
170 [_nextResponder performSelector:_cmd withObject:event]; 170 [_nextResponder performSelector:_cmd withObject:event];
171 } 171 }
172 172
173 -(void)rightMouseUp:(NSEvent *)event { 173 -(void)rightMouseUp:(NSEvent *)event {
174 [_nextResponder performSelector:_cmd withObject:event]; 174 [_nextResponder performSelector:_cmd withObject:event];
175 } 175 }
176 176
177 -(void)rightMouseDown:(NSEvent *)event { 177 -(void)rightMouseDown:(NSEvent *)event {
178 [_nextResponder performSelector:_cmd withObject:event]; 178 [_nextResponder performSelector:_cmd withObject:event];
179 } 179 }
180 180
181 -(void)rightMouseDragged:(NSEvent *)event { 181 -(void)rightMouseDragged:(NSEvent *)event {
182 [_nextResponder performSelector:_cmd withObject:event]; 182 [_nextResponder performSelector:_cmd withObject:event];
183 } 183 }
184 184
185 -(void)noop:sender { 185 -(void)noop:sender {
186 } 186 }
187 187
188 @end 188 @end
Powered by Google Project Hosting