How to let NSTokenField know objectValue has changed state (but not identity)?
How to let NSTokenField know objectValue has changed state (but not identity)?
- Subject: How to let NSTokenField know objectValue has changed state (but not identity)?
- From: Tim Gogolin <email@hidden>
- Date: Tue, 10 May 2005 11:28:27 -0500
More experimenting with NSTokenField...
I have a NSTokenField using my own object for the representedObject
(I call it TokenInfo)... TokenInfo may (under some circumstances)
have an NSMenu, and selecting a menu causes the state of the
TokenInfo to change such that the 'displayString' may change.
Here's the problem: how do I communicate that the displayString for
the respresentedObject has changed to the NSTokenField? I tried sending
[ myTokenField setNeedsDisplay: YES], but that doesn't update the
token using the new display string. Apparently, NSTokenField caches
some information and is redrawing using the stale info. Fair enough,
but how do I tell it to lose the old info and recompute?
Bearing in mind the good advice I got from Timothy Wood last time I
had a NSTokenField question, I tried
[ myTokenField setObjectValue: [ myTokenField objectValue ] ];
which DOES cause the tokens to be redisplayed using the new value for
the token's display string. (yay!) But now I worry that a possible
(future) optimization Apple might make is
if( newObjVal != oldObjVal )
// do assignment here...
}
as is common in many accessor idioms, so perhaps I should be doing
[ myTokenField setObjectValue: [ [ myTokenField objectValue ] copy ] ];
but this is starting to feel a little silly... Is there a "more
recommended" way of letting the NSTokenField know that its
objectValue has changed state?
-- Tim Gogolin
_______________________________________________
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