Re: NSTextView, style, and weird Core Data issue
Re: NSTextView, style, and weird Core Data issue
- Subject: Re: NSTextView, style, and weird Core Data issue
- From: Matt Neuburg <email@hidden>
- Date: Wed, 26 Jul 2006 13:22:21 -0700
- Thread-topic: NSTextView, style, and weird Core Data issue
On or about 7/26/06 12:21 PM, thus spake "I. Savant"
<email@hidden>:
> Matt:
>
> My apologies if this seems a bit simplistic, but have you looked
> at -setTypingAttributes:? I would not expect the text view to "reset"
> them to some value just because the underlying text storage changed.
> You may need to manually reset the attributes when a new object is
> created / displayed.
>
> I think it may be displaying the typing attributes of a non-empty
> attributed string because those are the attributes at the current
> position.
>
> I may be entirely wrong, but this is just my guess. :-D
It doesn't seem simplistic, and it does work, and I had in fact thought of
something like this, but:
(1) I don't like it, because here I was working happily in the model and
suddenly I'm supposed to reach out and munge the view? Isn't the whole point
of having the NSTextView bound thru to Core Data that it should do all this
automatically?
(2) If this is necessary, then why does it work properly when the attributed
string consists of a space? Clearly in that case the text view *does*
"reset" the typing attributes just because the underlying text store
changed. And the NSTextView does have "default" attributes, after a fashion,
so yes, I would have expected that emptying out the text storage *would*
reset the typing attributes (to the NSTextView's default attibutes).
I guess what I'm saying is, that's a great suggestion, but at the same time,
is there a case to be made that the behavior I'm seeing is unexpected (i.e.
wrong)? m.
PS The really interesting thing about your idea here is that it seems to
imply that this has nothing to do with Core Data - that emptying an
NSTextView's text storage doesn't reset the current typing attributes. That
is an hypothesis I'll have to test.
> On Jul 26, 2006, at 3:15 PM, Matt Neuburg wrote:
>
>> I'm having a weird problem where after displaying one entity, a new
>> entity
>> displayed in the same NSTextView has the styling left over from the
>> previous
>> entity.
>>
>> Let me set the scene. This is an ultra-simple Core Data app, with a
>> single
>> entity that has an NSData "facts" attribute. The NSTextView is
>> bound to this
>> attribute in the usual way, by way of an NSArrayController, via its
>> own
>> attributedString (using NSUnarchiveFromData).
>>
>> So here's the deal. I type something into the NSTextView. Then I
>> select all
>> (in the NSTextView) and type command-U, for Underline. Now all the
>> text in
>> the NSTextView is underlined.
>>
>> Now I press the New button, which is connected to the
>> NSArrayController's
>> add: action. The NSTextView goes blank; it is displaying the new
>> entity,
>> which is empty. I start typing, **and the typing is underlined**.
>>
>> That's very bad. I want a new entity to have "plain" styling.
>>
>> Okay, I'm open to suggestions! Let me tell you what I've done to
>> work around
>> the problem, because this, too, is very weird. On my entity's
>> awakeFromInsert, I store the archived version of an
>> NSAttributedString into
>> the "facts". If this attributed string has an empty string (@""), that
>> doesn't help! But if this attributed string has content - for
>> example, a
>> space (@" ") - it solves the problem!!!
>>
>> Unfortunately this solution is totally unacceptable, because I
>> don't want
>> every new entity's "facts" starting out with a blank space as its
>> content.
>> I'm wondering if anyone has any experience with this problem. Why
>> is the
>> NSTextView retaining the styling from the previously displayed
>> entity? Is
>> this a bug? m.
>>
>> --
>> matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
>> pantes anthropoi tou eidenai oregontai phusei
>> AppleScript: the Definitive Guide - Second Edition!
>> http://www.amazon.com/gp/product/0596102119
>> Take Control of Word 2004, Tiger, and more -
>> http://www.takecontrolbooks.com/tiger-customizing.html
>> Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40gmail.com
>>
>> This email sent to email@hidden
>
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.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