How to do a mixed input NSTokenField

731 Views Asked by At

I'm trying to get an NSTokenField working that allows editing to a similar post here.

The answer that was provided gave me the key but something is still off. What should the token character set be set as? My tags will be in this format "< token text >". Setting the character tokenizer to " " results in the " " between words being removed.

What should I be using as the token character set? This is driving me crazy!

1

There are 1 best solutions below

2
On BEST ANSWER

I haven't tried this, but I would use " " as the tokenizer and then add a space at the end of your display string which is not in your editing string.

So -tokenField:displayStringForRepresentedObject: would return "Hello " and -tokenField:editingStringForRepresentedObject: would return "Hello".

The alternative would be using "<" and ">" as the tokenizing characters, but I could see a lot of potential issues arising from that.