Is it possible to get an event when you click on a token in a NSTokenField?
Clicking token in NSTokenField
Asked Answered
Seeing as those tokens (NSTokenFieldCell
s) 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:
).
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
NSTokenFieldCell
s 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.