Document not Saving Text View Attachment
Document not Saving Text View Attachment
- Subject: Document not Saving Text View Attachment
- From: Gordon Apple <email@hidden>
- Date: Sat, 20 Feb 2010 11:11:44 -0600
- Thread-topic: Document not Saving Text View Attachment
I have a window with an NSTextView. If I edit the text normally, even
adding a single character, it behaves properly, I can save, close, reopen,
and the change is present. If I close after edit, it asks to save, like it
is supposed to. However, if I programmatically insert an attachment (with
undo/redo invocations) to the NSTextStorage, e.g., an icon, manually save,
close, reopen, -- it is not there. If I insert the attachment and close, it
does ask to save, but again, reopening does not show it. However, this
indicates that the change count is getting properly updated. If I insert
the attachment, then add a character elsewhere, then save/close, or
close/tell-to-save, both the attachment and the edit are present on reopen.
Since I'm making the change to the text storage, and it shows up
correctly in the view, I don't understand how "save" misses the change when
it streams it to data.
Am I missing something here? Is there something else I need to do to
make programmatic attachment insertions work properly?
Because the attachment edit is done programmatically, is there something
akin to "end edit" I need to call to make this take? I tried bracketing the
insertion with beginedit/endedit to no avail. I tried the following after
inserting, where "string" is the attachment character and attributes, but
that didn't help either.
[store insertAttributedString:string atIndex:index];
NSRange range = NSMakeRange(index, 0);
[store edited:NSTextStorageEditedAttributes |
NSTextStorageEditedCharacters range:range changeInLength:[string length]];
Additional info:
The NSTextView (tv) is created programmatically and has binding as follows:
// Set binding to update continuously. Otherwise, edits won't be
saved.
NSDictionary* options = [NSDictionary dictionaryWithObject:[NSNumber
numberWithBool:YES] forKey:NSContinuouslyUpdatesValueBindingOption];
[tv bind:@"attributedString" toObject:ddController
withKeyPath:@"shot.prompterText" options:options];
The local storage in the "shot" object is:
@property(assign) NSTextStorage* prompterText; // Actually stored in a
Dictionary.
_______________________________________________
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:
This email sent to email@hidden