diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j old mode 100755 new mode 100644 index 1498d2033..004459a65 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -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; } diff --git a/Tests/Manual/CPTokenFieldTest/AppController.j b/Tests/Manual/CPTokenFieldTest/AppController.j index 0b226e2d6..667122f5e 100644 --- a/Tests/Manual/CPTokenFieldTest/AppController.j +++ b/Tests/Manual/CPTokenFieldTest/AppController.j @@ -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],