• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting the contents of an NSTokenField programatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the contents of an NSTokenField programatically


  • Subject: Re: Setting the contents of an NSTokenField programatically
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Thu, 5 May 2005 08:44:46 -0700


On May 5, 2005, at 6:43 AM, Tim Gogolin wrote:
That's what I'm trying to do, yes. Its just not behaving as I wish.
I am trying this in a controller instantiated in awakeFromNib, which is about as early as I can get. When I call setStringValue, the string is set AS PLAIN TEXT in the NSTokenField, when what I want to happen is for the little blue bubbles to appear. When I simply type that same string (as a user interacting with the window), then the tokens appear correctly (indicating that my tokenField:displayStringForRepresentedObject: is called and working correctly).


Apparently, setStringValue: does not trigger the same "check for tokens" logic that a user typing into the field causes. My question: How can I force the NSTokenField to look at the string contents of the entire field and "tokenize" it all?



The objectValue of a NSTokenField is an NSArray of tokens. The tokens can be strings or some class your delegate understands as the represented object for a token. So, -setStringValue: is presumably equivalent to -setObjectValue:[NSArray arrayWithObject:aString].

You should be able to call -setObjectValue: with the correct set of tokens. You'd still have to do the tokenization, but hopefully this is easy.

-tim

_______________________________________________
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


  • Follow-Ups:
    • Re: Setting the contents of an NSTokenField programatically
      • From: Tim Gogolin <email@hidden>
References: 
 >Setting the contents of an NSTokenField programatically (From: Tim Gogolin <email@hidden>)
 >Re: Setting the contents of an NSTokenField programatically (From: Scott Anguish <email@hidden>)
 >Re: Setting the contents of an NSTokenField programatically (From: Tim Gogolin <email@hidden>)

  • Prev by Date: Re: Spotlight -- Metadata importer vs file package containing rtfd files
  • Next by Date: Re: Spotlight -- Metadata importer vs file package containing rtfd files
  • Previous by thread: Re: Setting the contents of an NSTokenField programatically
  • Next by thread: Re: Setting the contents of an NSTokenField programatically
  • Index(es):
    • Date
    • Thread