Clicking token in NSTokenField
Asked Answered
A

1

8

Is it possible to get an event when you click on a token in a NSTokenField?

Allegedly answered 3/1, 2011 at 21:36 Comment(0)
S
4

Seeing as those tokens (NSTokenFieldCells) inherit from the NSCell class, in theory, yes, you can have them send an event by giving them an action and a target (-setAction: and -setTarget: respectively, and if you want to give the tokens menus when pressed, use -setMenu:).

Sharisharia answered 3/1, 2011 at 21:55 Comment(4)
How/where should I set the action which will be fired when clicking on a token field cell?Rockwell
In your UI controller (whichever class you use to control actions associated with the user interface), you should declare a method that will get called when these tokens get pressed. By default, there's no way to access NSTokenFieldCells from the NSTokenField to set the action and target, though, so you might have to do some subclassing to get it to work correctly.Sharisharia
I have created a MyNSTokenField to return MyNSTokenFieldCell (through <code>+ (Class)cellClass</code>, whereby I set MyNSTokenFieldCell's Target and Action though no event was sent. Any idea what else I could do to get an event when clicked?Allegedly
I'm wondering the same thing. Did you managed to get it solved?Displease

© 2022 - 2024 — McMap. All rights reserved.