Search code examples
objective-ccocoamacosnstokenfield

Custom-drawn tokens in NSTokenField


Is there a way to have custom tokens inside an NSTokenField? By "custom" I mean I would like to draw them in a custom way -- custom hover, background image, etc.


Solution

  • Yes, this is possible, but you'll have to resort to using private APIs, which you don't want if you intend on publishing your app to the Mac App Store. I have contacted Apple about this, and they have confirmed that there is no way of doing this without private APIs - if one needs difference appearance using only public APIs, one must create one's own control from scratch.

    If you still want to do this using private APIs, look into BWToolkit. BWTokenField uses these private APIs to modify the token appearance. That should be a good starting point. But it takes a while to figure it all out and tweak things until one gets one's desired effect.