One Last Help request (Hopefully)

Discussion in 'Mac Programming' started by stadidas, Nov 22, 2006.

  1. stadidas macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #1
    I've got only a couple of more things to do on my app before I can really start using it properly (thanks to everyone here who has helped).
    First off I need to be able to undo edits that are made to a text field. I have a rough idea of what to do and have put this method in which I think will listen for any edits:
    Code:
    - (void)startObservingDetails:(NSObjectController *)details
    {
    	[details addObserver:self
    			  forKeyPath:@"myBalance"
    				 options:NSKeyValueObservingOptionOld
    				 context:NULL];
    }
    
    I thought that calling this from the -init method would work, but it doesn't appear to.
    I also need to get revert working. In my loadDataRepresentation: I have this code to check if revert was called:
    Code:
    if (currentDate != nil) {
    		NSLog(@"Revert Code needs to go here.");
    	}
    
    This code appears to work, I just need to know how to tell the interface objects to update.

    I have uploaded the project here, which will hopefully be the last time I have to do it as I have got pretty much everything working. Thanks again to everyone who was kind enough to help on these forums.
     
  2. ATG macrumors regular

    Joined:
    Aug 7, 2005
    #2
    An NSTextField should have undos already hooked up for you. You shouldn't have to do it yourself.

    Revert should work out of the box too I think. I'm not entirely sure.
     
  3. stadidas thread starter macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #3
    NSTextField does register and edit and it undoable as long as you have the text box selected. If you tab out of it or click somewhere else the edit is forgotten, so it's not being put on the undo stack.
    I have isolated the point in the code where revert is carried out using a NSLog call. At this point I need to tell the interface to update to show the model that has been reloaded.
    Unfortunately I don't know how to correct either of these things.
     

Share This Page