focus expression text field at startup -> version 1.2
[LeanCalc.git] / Sources / MyDocument.m
index 6791d37..519ffe0 100644 (file)
@@ -29,6 +29,7 @@
 
 - (void)dealloc {
        [calculations release];
+       [super dealloc];
 }
 
 
        }
        
        [arrayController setSelectionIndex:[calculations count] - 1];
+
 }
 
 
+
 - (IBAction)commit:(id)sender {
 
        if (![[sender stringValue] length]) return;
 
 - (void)addItem {
 
-       [arrayController add:self];
+       Calculation *newcalc = [[[Calculation alloc] init] autorelease];
+       [arrayController addObject:newcalc];
        int count = [calculations count];
-       id last = [calculations objectAtIndex:count - 1];
        id secondtolast = [calculations objectAtIndex:count - 2];
-       [secondtolast setValue:last forKey:@"next"];
+       [secondtolast setValue:newcalc forKey:@"next"];
        
 }
 
 }
 
 
-- (void)windowControllerDidLoadNib:(NSWindowController *) aController {
+- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
+       NSWindow *win = [aController window];
+       [win performSelector:@selector(makeFirstResponder:) withObject:expressionField afterDelay:0.0];
     [super windowControllerDidLoadNib:aController];
 }