- Timestamp:
- 05/17/06 04:58:34 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/F-Script Anywhere/Source/FSAViewAssociationController.m
r153 r224 36 36 - (id)initWithFSAController:(FSAController *)fsa; 37 37 { 38 self = [super init WithWindowNibName: @"FSAViewAssociationPanel"];38 self = [super init]; 39 39 40 40 if (self != nil) { … … 47 47 if (label != nil) [[self window] setTitle: [NSString stringWithFormat: @"%@: %@", [[self window] title], label]]; 48 48 bullseyeCursor = [[NSCursor alloc] initWithImage: bullseyeImage hotSpot: NSMakePoint(6, 7)]; 49 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTextDidChange:) name: NSControlTextDidChangeNotification object: variableNameField];50 [[captureButton cell] setShowsStateBy: NSContentsCellMask | NSChangeGrayCellMask];51 [captureButton setState: NSOffState];52 [self update: nil];53 49 } 54 50 return self; … … 65 61 } 66 62 67 - (IBAction)update:(id)sender;68 {69 NSString *variableName = [variableNameField stringValue];70 BOOL canAssignToVariable = NO;71 [browseButton setEnabled: selectedElement != nil];72 [statusField setStringValue: @""];73 if ([variableName length] != 0) {74 if (![FSInterpreter validateSyntaxForIdentifier: variableName]) {75 [statusField setStringValue: @"Invalid name: contains spaces, punctuation or non-ASCII characters"];76 } else if (selectedElement != nil) {77 [statusField setStringValue: @"Click ÒAssociateÓ to assign to this variable"];78 canAssignToVariable = YES;79 }80 }81 [associateButton setEnabled: canAssignToVariable];82 [variableNameField setEnabled: [captureButton state] == NSOffState];83 }84 85 63 - (void)stopCapturingVoluntarily:(BOOL)voluntary; 86 64 { 87 65 FSALog(@"stopping capture"); 88 66 [[NSNotificationCenter defaultCenter] removeObserver: self name: NSMenuWillSendActionNotification object: nil]; 89 [captureButton setState: NSOffState];90 [self update: nil];91 67 if (voluntary) { 92 68 FSALog(@"voluntary!"); 93 69 [[self window] makeKeyAndOrderFront: self]; 94 70 [bullseyeCursor pop]; 95 [variableNameField becomeFirstResponder];96 71 } 97 72 } … … 158 133 159 134 FSALog(@"%4u>capturing one", capture); 160 [captureButton setState: NSOnState];161 135 [bullseyeCursor push]; 162 163 136 captureElement: 164 137 [bullseyeCursor set]; … … 192 165 contentView = [eventWindow contentView]; 193 166 view = [[contentView superview] hitTest: [event locationInWindow]]; 194 if (view == captureButton) {195 [NSApp discardEventsMatchingMask: NSAnyEventMask & ~NSKeyUpMask beforeEvent: event];196 FSALog(@"%4u<stop capture [capture button]", capture);197 [self stopCapturingVoluntarily: YES];198 NS_VOIDRETURN;199 }200 167 if (view == nil) { 201 168 [self captureOneView]; … … 214 181 [self _addElementToMenu: eventWindow]; 215 182 NS_HANDLER 216 [descriptionField setStringValue: 217 [NSString stringWithFormat: @"Çan exception occurred: %@È", localException]]; 183 [self alertWithString:[NSString stringWithFormat: @"Çan exception occurred: %@È", localException]]; 218 184 NS_ENDHANDLER 219 185 [NSMenu popUpContextMenu: viewHierarchyMenu withEvent: event forView: view]; 220 if ([captureButton state] == NSOnState) goto captureElement; 186 [self stopCapturingVoluntarily: YES]; 187 // if ([captureButton state] == NSOnState) goto captureElement; 221 188 FSALog(@"%4u<stop capture [fell through to end]", capture); 222 189 } … … 224 191 - (IBAction)captureView:(id)sender 225 192 { 226 [statusField setStringValue: @"Click inside one of this applicationÕs windows to select."];227 193 [selectedElement release]; selectedElement = nil; 228 [self update: nil];229 194 [self captureOneView]; 230 195 } … … 234 199 FSALog(@"element selected: %@", element); 235 200 NS_DURING 236 [descriptionField setStringValue: [element description]];237 201 [selectedElement release]; 238 202 selectedElement = [element retain]; 239 203 [[self window] orderFront: self]; 240 204 NS_HANDLER 241 [descriptionField setStringValue: 242 [NSString stringWithFormat: @"Çan exception occurred: %@È", localException]]; 205 [self alertWithString:[NSString stringWithFormat: @"Çan exception occurred: %@È", localException]]; 243 206 NS_ENDHANDLER 244 207 [viewHierarchyMenu release]; viewHierarchyMenu = nil; … … 248 211 { 249 212 [self setSelectedElement: [sender representedObject]]; 250 [self captureOneView]; 213 [system browse: selectedElement]; 214 // [self captureOneView]; 251 215 } 252 216 … … 259 223 } 260 224 261 - (void)controlTextDidChange:(NSNotification *)notification;262 {263 [self update: nil];264 }265 266 - (IBAction)defineVariable:(id)sender;267 {268 NS_DURING269 NSString *variableName = [variableNameField stringValue];270 [statusField setStringValue: @"AssociatingÉ"];271 [interpreter setObject: selectedElement forIdentifier: variableName];272 [statusField setStringValue: [NSString stringWithFormat: @"Assigned variable Ò%@Ó", variableName]];273 NS_HANDLER274 [statusField setStringValue: [NSString stringWithFormat: @"Assocation failed: %@", localException]];275 NS_ENDHANDLER276 }277 278 225 - (IBAction)viewInObjectBrowser:(id)sender; 279 226 { 280 227 FSALog(@"system: %@", system); 281 228 [system browse: selectedElement]; 282 [statusField setStringValue: @"Opened object browser"]; 229 } 230 231 - (void)alertWithString:(NSString *)alertString 232 { 233 [NSAlert alertWithMessageText:alertString 234 defaultButton:nil 235 alternateButton:nil 236 otherButton:nil 237 informativeTextWithFormat:nil]; 283 238 } 284 239
Note:
See TracChangeset
for help on using the changeset viewer.