• 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
Setting the contents of an NSTokenField programatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Setting the contents of an NSTokenField programatically
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: NSTextView - text wrapping
  • Next by Date: Re: kEventParamMenuRef (was: _NSGetCarbonMenu)
  • Previous by thread: Re: CFPreferencesSetAppValue
  • Next by thread: Re: Setting the contents of an NSTokenField programatically
  • Index(es):
    • Date
    • Thread