nstokenfield

Clicking token in NSTokenField

痞子三分冷 提交于 2019-12-04 04:32:46
Is it possible to get an event when you click on a token in a NSTokenField? 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: ). 来源: https://stackoverflow.com/questions/4588599/clicking-token-in-nstokenfield

Autocomplete with twitter usernames in text field (cocoa)

。_饼干妹妹 提交于 2019-12-03 09:08:55
I was looking at NSTokenField, NSTextField and NSTextView with no luck to do the following: I am writing a Twtitter client and when you want to twitter a new Tweet then you begin to write in a text field for example: Going to make coffee, @pe When you begin to write a @ then I would like to help the user to autocomplete the username for example @peter . I have a NSArray with the usernames like: NSArray *usernames = [NSArray arrayWithObjects:@"@andreas", @"@clara", @"@jeena", @"@peter"] What should I do to enable a simple autocompletation? I'd be happy if you would have to press F5 or something

NSTokenField catch some NSEvents

折月煮酒 提交于 2019-12-02 09:28:08
I need implement Command + Enter, Command + O and Esc shotcuts for NSTokenField and solutonns like https://stackoverflow.com/a/18486965/1067147 not worked because -(void)noop:(SEL)sel isn't useful. My way is to create category for upper-in-hierarchy class NSView (also I try it for NSTextView but no luck): // NSView+WideInterpreter.h #import <Cocoa/Cocoa.h> #define kNotificationTokenModifier @"kNotificationTokenModifier" #define kNotificationTokenModifier_modifier @"kNotificationTokenModifier_modifier" typedef enum{ BMTokenModifier_CommandEnter = 10, BMTokenModifier_CommandO, BMTokenModifier

NSTokenField does not let me type other strings than tokenField:completionsForSubstring:… returns

微笑、不失礼 提交于 2019-12-01 08:30:05
My issue is that NSTokenField does not allow me to type any text I want, it's only allow me to type strings that are included in the NSArray that tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: returns. - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex { return [NSArray arrayWithObjects:@"AA", @"BB", @"CC", @"DD", nil]; } My NSTokenField can only contain the above text-tokens. If I type for example XXX it does not appeared and it cannot be added.

NSTokenField with mixed token/string input, possible?

天大地大妈咪最大 提交于 2019-11-28 06:58:04
When entering an invalid email in Mail's NSTokenField one get's this (a mix of token and plain string values ): Is there any recommendable way to accomplish this? Is NSTokenField even the right tool for this? Or would I be abusing it? In this particular project I need to allow the user to enter a file name pattern (there are several other use cases though) , with support for predefined tokens. Right now I'm requiring the input to be entered like this: Glue Text %[Tag]Other Glue Text%[Another Tag]More Text I'd like to change this to some fool-proof graphical solution like this: NSTokenField

NSTokenField and deleting tokens

↘锁芯ラ 提交于 2019-11-28 01:51:51
问题 My app allows users to attach tags to certain model objects (subclasses of NSManagedObject). The Tag class is also a subclass of NSManagedObject. I decided to use NSTokenField to display the tags, where each token holds an instance of Tag as the represented object. It all works pretty good but I'm stuck in situations where the user deletes a token as I want to check whether the associated Tag has become obsolete and should be deleted. I was expecting a method in NSTokenFieldDelegate or

NSTokenField with mixed token/string input, possible?

时间秒杀一切 提交于 2019-11-27 05:43:20
问题 When entering an invalid email in Mail's NSTokenField one get's this (a mix of token and plain string values ): Is there any recommendable way to accomplish this? Is NSTokenField even the right tool for this? Or would I be abusing it? In this particular project I need to allow the user to enter a file name pattern (there are several other use cases though) , with support for predefined tokens. Right now I'm requiring the input to be entered like this: Glue Text %[Tag]Other Glue Text%[Another