Ignore:
Timestamp:
05/17/06 04:58:34 (18 years ago)
Author:
rchin
Message:

Object For Target... button now works as it should.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/F-Script Anywhere/Source/FSAViewAssociationController.m

    r153 r224  
    3636- (id)initWithFSAController:(FSAController *)fsa;
    3737{
    38     self = [super initWithWindowNibName: @"FSAViewAssociationPanel"];
     38    self = [super init];
    3939
    4040    if (self != nil) {
     
    4747        if (label != nil) [[self window] setTitle: [NSString stringWithFormat: @"%@: %@", [[self window] title], label]];
    4848        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];
    5349    }
    5450    return self;
     
    6561}
    6662
    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 
    8563- (void)stopCapturingVoluntarily:(BOOL)voluntary;
    8664{
    8765    FSALog(@"stopping capture");
    8866    [[NSNotificationCenter defaultCenter] removeObserver: self name: NSMenuWillSendActionNotification object: nil];
    89     [captureButton setState: NSOffState];
    90     [self update: nil];
    9167    if (voluntary) {
    9268        FSALog(@"voluntary!");
    9369        [[self window] makeKeyAndOrderFront: self];
    9470        [bullseyeCursor pop];
    95         [variableNameField becomeFirstResponder];       
    9671    }
    9772}
     
    158133   
    159134    FSALog(@"%4u>capturing one", capture);
    160     [captureButton setState: NSOnState];
    161135    [bullseyeCursor push];
    162 
    163136captureElement:
    164137    [bullseyeCursor set];
     
    192165        contentView = [eventWindow contentView];
    193166        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         }
    200167        if (view == nil) {
    201168            [self captureOneView];
     
    214181        [self _addElementToMenu: eventWindow];
    215182    NS_HANDLER
    216         [descriptionField setStringValue:
    217             [NSString stringWithFormat: @"Çan exception occurred: %@È", localException]];
     183        [self alertWithString:[NSString stringWithFormat: @"Çan exception occurred: %@È", localException]];
    218184    NS_ENDHANDLER
    219185    [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;
    221188    FSALog(@"%4u<stop capture [fell through to end]", capture);
    222189}
     
    224191- (IBAction)captureView:(id)sender
    225192{
    226     [statusField setStringValue: @"Click inside one of this applicationÕs windows to select."];
    227193    [selectedElement release]; selectedElement = nil;
    228     [self update: nil];
    229194    [self captureOneView];
    230195}
     
    234199    FSALog(@"element selected: %@", element);
    235200    NS_DURING
    236         [descriptionField setStringValue: [element description]];
    237201        [selectedElement release];
    238202        selectedElement = [element retain];
    239203        [[self window] orderFront: self];
    240204    NS_HANDLER
    241         [descriptionField setStringValue:
    242             [NSString stringWithFormat: @"Çan exception occurred: %@È", localException]];
     205        [self alertWithString:[NSString stringWithFormat: @"Çan exception occurred: %@È", localException]];
    243206    NS_ENDHANDLER
    244207    [viewHierarchyMenu release]; viewHierarchyMenu = nil;
     
    248211{
    249212    [self setSelectedElement: [sender representedObject]];
    250     [self captureOneView];
     213    [system browse: selectedElement];
     214//    [self captureOneView];
    251215}
    252216
     
    259223}
    260224
    261 - (void)controlTextDidChange:(NSNotification *)notification;
    262 {
    263     [self update: nil];
    264 }
    265 
    266 - (IBAction)defineVariable:(id)sender;
    267 {
    268     NS_DURING
    269         NSString *variableName = [variableNameField stringValue];
    270         [statusField setStringValue: @"AssociatingÉ"];
    271         [interpreter setObject: selectedElement forIdentifier: variableName];
    272         [statusField setStringValue: [NSString stringWithFormat: @"Assigned variable Ò%@Ó", variableName]];
    273     NS_HANDLER
    274         [statusField setStringValue: [NSString stringWithFormat: @"Assocation failed: %@", localException]];
    275     NS_ENDHANDLER
    276 }
    277 
    278225- (IBAction)viewInObjectBrowser:(id)sender;
    279226{
    280227    FSALog(@"system: %@", system);
    281228    [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];
    283238}
    284239
Note: See TracChangeset for help on using the changeset viewer.