| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.4 and later.
|
| Declared in | NSTokenField.h |
NSTokenField is a subclass of NSTextField that provides tokenized editing similar to the address field in Mail.app.
NSTokenField uses an NSTokenFieldCell to implement much of the control’s functionality. NSTokenField provides cover methods for most of NSTokenFieldCell’s methods, which invoke the corresponding cell method.
– tokenField:displayStringForRepresentedObject: delegate method
– tokenField:styleForRepresentedObject: delegate method
– tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: delegate method
– tokenField:editingStringForRepresentedObject: delegate method
– tokenField:representedObjectForEditingString: delegate method
– tokenField:shouldAddObjects:atIndex: delegate method
– tokenField:readFromPasteboard: delegate method
– tokenField:writeRepresentedObjects:toPasteboard: delegate method
– tokenField:hasMenuForRepresentedObject: delegate method
– tokenField:menuForRepresentedObject: delegate method
Returns the default completion delay.
+ (NSTimeInterval)defaultCompletionDelay
The default completion delay is 0.
NSTokenField.h
Returns the default tokenizing character set.
+ (NSCharacterSet *)defaultTokenizingCharacterSet
The default tokenizing character set is “,”.
NSTokenField.hReturns the receiver’s completion delay.
- (NSTimeInterval)completionDelay
NSTokenField.hSets the receiver’s completion delay.
- (void)setCompletionDelay:(NSTimeInterval)delay
NSTokenField.hSets the recevier’s tokenizing character set to characterSet.
- (void)setTokenizingCharacterSet:(NSCharacterSet *)characterSet
NSTokenField.hReturns the token style of the receiver.
- (void)setTokenStyle:(NSTokenStyle)style
NSTokenField.hReturns the receiver’s tokenizing character set.
- (NSCharacterSet *)tokenizingCharacterSet
NSTokenField.hReturns the receiver’s token style.
- (NSTokenStyle)tokenStyle
NSTokenField.hAllows the delegate to provide an array of appropriate completions for the contents of the receiver.
- (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
The token field where editing is occurring.
The partial string that is to be completed.
The index of the token being edited.
Optionally, you can return by-reference an index into the returned array that specifies which of the completions should be initially selected. If none are to be selected, return NULL.
An array of possible completions.
The default behavior of this method provides no completions.
NSTokenField.hAllows the delegate to provide a string to be displayed as a proxy for the given represented object.
- (NSString *)tokenField:(NSTokenField *)tokenField displayStringForRepresentedObject:(id)representedObject
The token field.
A represented object of the token field.
The string to be used as a proxy for representedObject. If you return nil or do not implement this method, then representedObject is displayed as the string.
The represented object must implement the NSCoding protocol.
NSTokenField.hAllows the delegate to provide a string to be edited as a proxy for the representedObject.
- (NSString *)tokenField:(NSTokenField *)tokenField editingStringForRepresentedObject:(id)representedObject
If you return nil or do not implement this method, then the value returned by tokenField:displayStringForRepresentedObject: is used for editing. The represented object must implement the NSCoding protocol.
NSTokenField.hAllows the delegate to specify whether the given represented object provides a menu.
- (BOOL)tokenField:(NSTokenField *)tokenField hasMenuForRepresentedObject:(id)representedObject
The token field.
A represented object of the token field.
YES if the represented object has a menu, NO otherwise.
By default tokens have no menus.
NSTokenField.hAllows the delegate to provide a menu for the specified represented object.
- (NSMenu *)tokenField:(NSTokenField *)tokenField menuForRepresentedObject:(id)representedObject
The token field.
A represented object of the token field.
The menu associated with the represented object.
The returned menu should be autoreleased. By default tokens do not return menus.
NSTokenField.hAllows the delegate to return an array of objects representing the data read from the specified pasteboard.
- (NSArray *)tokenField:(NSTokenField *)tokenField readFromPasteboard:(NSPasteboard *)pboard
NSTokenField.hAllows the delegate to provide a represented object for editingString.
- (id)tokenField:(NSTokenField *)tokenField representedObjectForEditingString:(NSString *)editingString
The represented object must implement the NSCoding protocol. If your application uses some object other than an NSString for their represented objects, you should return a new, autoreleased instance of that object from this method.
NSTokenField.hAllows the delegate to validate the tokens to be added to the receiver at a particular location.
- (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index
The token field being validated.
An array of tokens to be inserted in the receiver at index.
The index of the receiver in which the array of tokens to be validated (tokens) will be inserted.
The array of tokens to be inserted.
The delegate can return the array unchanged or return a modified array of tokens. To reject the add completely, return an empty array. Returning nil causes an error.
NSTokenField.hAllows the delegate to return the token style for editing the specified represented object.
- (NSTokenStyle)tokenField:(NSTokenField *)tokenField styleForRepresentedObject:(id)representedObject
The delegate should return NSDefaultTokenStyle, NSPlainTextTokenStyle or NSRoundedTokenStyle.
NSTokenField.hSent so the delegate can write custom pasteboard types to the pasteboard for the given represented objects.
- (BOOL)tokenField:(NSTokenField *)tokenField writeRepresentedObjects:(NSArray *)objects toPasteboard:(NSPasteboard *)pboard
The token field.
An array of represented objects associated with the token field.
The pasteboard to which to write the custom pasteboard types.
YES if the operation succeeded, NO otherwise.
The display strings for the represented objects have already been placed on the pasteboard as both NSStringPboardType and an array of NSString objects.
NSTokenField.h
Last updated: 2007-03-07