Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ending Editing when Doc Saves?




On 30 May 2008, at 20:33, David Carlisle wrote:

This is the approach I ended up taking:

// in MyDocument.m
- (void) saveDocument:(id)sender {
[[self windowControllers] makeObjectsPerformSelector:@selector(myPrepareToSave:)];
[super saveDocument:sender];
}


// in MyWindow.m
- (void) myPrepareToSave:(id)sender {
	[[self window] makeFirstResponder:[self window]];
}

I couldn't find a more general save operation to modify in MyDocument, so I modified both saveDocument, and saveDocumentAs. I can modify others later if needed. I was thinking there might be something like (BOOL) shouldSaveDocument, but I didn't see it.

Well I would suggest either

-saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:

or

-saveDocumentWithDelegate:didSaveSelector:contextInfo:


In particular, consider the scenario of the user closing an unsaved doc. If they choose "Save" from the prompt, I'm pretty certain that the actual document saving does not go through either of the IBAction methods.


The myPrepareToSave method in MyWindow allowed me to experiment with the commitEditing method. I tried sending it to either my NSWindowController or to the NSArrayController which is bound to the NSCollectionView which contains the NSTextField that needed to end editing. Neither approach worked, so I stuck with using makeFirstResponder.

DC

On May 29, 2008, at 6:41 AM, Dave Fernandes wrote:

Make the window the first responder in your document's saveDocument method...

- (IBAction)saveDocument:(id)sender
{
	NSWindow* window = [self windowForSheet];
	[window makeFirstResponder:window];
	[super saveDocument:sender];
}

On May 28, 2008, at 11:15 PM, David Carlisle wrote:

If I'm adding text to an NSTextField, then I select Save, somehow the message needs to get to the NSTextField wherever it is that it needs to terminate editing and send its contents to the model before the model is saved. I don't see how I should go about implementing that? Any suggestions are welcome.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Ending Editing when Doc Saves? (From: David Carlisle <email@hidden>)
 >Re: Ending Editing when Doc Saves? (From: Dave Fernandes <email@hidden>)
 >Re: Ending Editing when Doc Saves? (From: David Carlisle <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.