mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-15 04:54:29 +00:00
Fix nil representedObjectForEditingString: response handling.
If `tokenField: representedObjectForEditingString:` returns nil, act the same as if the delegate method didn't exist. This matches Cocoa.
This commit is contained in:
1 parent
d0769ec360
commit
19b53746cf
1 file changed
+9
-8
@@ -1133,24 +1133,25 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
The delegate method should return a represented object for the provided string which
|
||||
may have been typed by the user or selected from the completion menu. If the method is
|
||||
not implemented, the string is assumed to be the represented object.
|
||||
not implemented, or returns nil, the string is assumed to be the represented object.
|
||||
|
||||
@ignore
|
||||
*/
|
||||
- (id)_representedObjectForEditingString:(CPString)aString
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
var delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tokenField:representedObjectForEditingString:)])
|
||||
return [delegate tokenField:self representedObjectForEditingString:aString];
|
||||
{
|
||||
var token = [delegate tokenField:self representedObjectForEditingString:aString];
|
||||
if (token !== nil && token !== undefined)
|
||||
return token;
|
||||
// If nil was returned, assume the string is the represented object. The alternative would have been
|
||||
// to not add anything to the object value array for a nil response.
|
||||
}
|
||||
|
||||
return aString;
|
||||
}
|
||||
|
||||
//
|
||||
// If you return nil or don't implement these delegate methods, we will assume
|
||||
// editing string = display string = represented object
|
||||
// - (NSString *)tokenField:(NSTokenField *)tokenField editingStringForRepresentedObject:(id)representedObject;
|
||||
//
|
||||
// We put the string on the pasteboard before calling this delegate method.
|
||||
// By default, we write the NSStringPboardType as well as an array of NSStrings.
|
||||
// - (BOOL)tokenField:(NSTokenField *)tokenField writeRepresentedObjects:(NSArray *)objects toPasteboard:(NSPasteboard *)pboard;
|
||||
|
||||
Reference in new issue
Block a user