Fixed: CPTokenField sends focus and blur notifications

This commit adds notifications for focus and blur on CPTokenField.

Attached is a modified Manual CPTokenFieldTest that observes these notifications.

Fixes #1396
This commit is contained in:
Andrew Hankinson committed 2013-04-07 20:50:50 -04:00
1 parent b3c60e56a6
commit 6ef5b46dd6
2 files changed
+27

No files matched your search

Executable → Regular
+6
View File
@@ -34,6 +34,8 @@
@import "CPWindow_Constants.j"
@global CPApp
@global CPTextFieldDidFocusNotification
@global CPTextFieldDidBlurNotification
#if PLATFORM(DOM)
@@ -392,6 +394,8 @@ CPTokenFieldDeleteButtonType = 1;
element.focus();
CPTokenFieldInputOwner = self;
}, 0.0);
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
}, 0.0);
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
@@ -430,6 +434,8 @@ CPTokenFieldDeleteButtonType = 1;
[self sendAction:[self action] to:[self target]];
}
[self textDidBlur:[CPNotification notificationWithName:CPTextFieldDidBlurNotification object:self userInfo:nil]];
return YES;
}
@@ -133,6 +133,17 @@ var STATES = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorad
[[self class] createTokenfieldContents:contentView withDelegate:self];
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkDidFocusNotification:)
name:CPTextFieldDidFocusNotification
object:nil]
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkDidBlurNotification:)
name:CPTextFieldDidBlurNotification
object:nil]
var popoverButton = [[CPButton alloc] initWithFrame:CGRectMake(15, 310, 0, 0)];
[popoverButton setTitle:"Token Field in a Popover"];
[popoverButton sizeToFit];
@@ -143,6 +154,16 @@ var STATES = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorad
[theWindow orderFront:self];
}
- (@action)checkDidFocusNotification:(CPNotification)aNotification
{
console.log("Field did focus");
}
- (@action)checkDidBlurNotification:(CPNotification)aNotification
{
console.log("Field did blur");
}
- (@action)openPopover:(id)sender
{
var aPopover = [CPPopover new],