Programmatically setting and retrieving values in from a NSTextView in a sheet
Programmatically setting and retrieving values in from a NSTextView in a sheet
- Subject: Programmatically setting and retrieving values in from a NSTextView in a sheet
- From: Mike Zornek <email@hidden>
- Date: Wed, 07 Jun 2006 17:18:15 -0400
I have an application where a user can highlight a row in a table and then
hit edit. This brings up a custom sheet where the user can edit the
attributes of the object. One of the attributes is a short message which is
displayed in a NSTextView that has multiple fonts turned off. The message
will only consist of regular characters and optionally some returns.
Because the sheet is also used when they create a new object and I don't
want the new object instantiated until they hit save on the custom sheet I
am not using bindings and am instead programmatically setting the values
when the sheet is opened and then retrieving them when the sheet is closed.
Over time I'm hitting some very strange behavior with the NSTextView in this
sheet. It appears as if I'm not setting it or clearing it out properly. It
feels like it is hanging on to previous string I've sent it or when I set
the value in the TextView it's being set in all of my object .. Not just the
current one selected. When is really strange because the rest of the fields
work fine.
Early on I was using the `setString:` method directly on the NSTextView to
set the value and then the `string` method to retrieve but was experiencing
this bug.
Over the web and IRC I'm now told I should use the textStorage system as
this is a known bug. I'm using this when raising the sheet:
[[[messageTextView textStorage] mutableString] setString:[[self invoice]
valueForKey:@"message"]];
And to get the string value and using
[[self invoice] setValue:[messageTextView string] forKey:@"message"];
But I don't think it's working right.
Oh, and when they hit the same button I'm issuing:
[invoiceEditorWindow makeFirstResponder:invoiceEditorWindow];
I do this so that the sheet tells the fields to commit editing. Not sure if
this is related.
Please show me how to set a NSTextView with a simple NSString, retrieve a
NSString from a NSTextView and if needed a way to reset a TextView so I can
evade this bug. I've been trying to kill this for many hours now and am
getting nowhere. Thanks.
~ Mike
--
Work: http://ClickableBliss.com
Play: http://MikeZornek.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden