Setting the contents of an NSTokenField programatically
Setting the contents of an NSTokenField programatically
- Subject: Setting the contents of an NSTokenField programatically
- From: Tim Gogolin <email@hidden>
- Date: Wed, 04 May 2005 21:51:10 -0500
Is there a sanctioned way to programatically set the contents of an
NSTokenField (with contents that are tokens, not plain strings)? I want
to preset the contents before the user sees the control, but I can't
figure out a straightforward way to do it.
I feel like I must be missing something obvious, this must be supported
via an API, yes?
[ tokenField setStringValue: @"blah" ] simply puts the string "blah" in
the edit field, even if it should have matched a token from the
delegate method tokenField:displayStringForRepresentedObject:.
Presumably the delegate method is only called when the edit field
changes due to user interaction, not a programatic setStringValue:.
I almost have something working by implementing the delegate method
tokenField:readFromPasteboard: to do what I want and fake a "paste"
call via [ [ tokenField currentEditor ] paste: nil ]. This allows me to
populate the NSTokenField correctly, and the strings tokenize as
expected, but now I need to be able to duplicate the default handling
of tokenField:readFromPasteboard: for drag&drop to work correctly (of
course), and I'm having difficulty implementing the default behavior.
In any case, this can't be the expected way of accomplishing this;
there must be a more straightforward way... right?
-- 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