From ba84e6d3e26d7a4be222fe7fe42cdb6bef3dfa3b Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 28 Oct 2009 00:12:03 -0700 Subject: [PATCH] Support for sendsActionOnEndEditing in CPControl. Only works for textfields right now. --- AppKit/CPControl.j | 3 ++- AppKit/CPTextField.j | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index d00f3aa6f..f9ddc817e 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -94,7 +94,8 @@ var CPControlBlackColor = [CPColor blackColor]; id _target; SEL _action; int _sendActionOn; - + BOOL _sendsActionOnEndEditing @accessors(property=sendsActionOnEndEditing); + // Mouse Tracking Support BOOL _continuousTracking; BOOL _trackingWasWithinFrame; diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index ebf0815c9..1b253d44c 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -269,8 +269,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); if (aDOMEvent && aDOMEvent.keyCode == CPReturnKeyCode) { - [owner sendAction:[owner action] to:[owner target]]; - [[owner window] makeFirstResponder:nil]; + [owner sendAction:[owner action] to:[owner target]]; + [owner selectText:nil]; } else if (aDOMEvent && aDOMEvent.keyCode == CPTabKeyCode) { @@ -666,6 +666,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); //post CPControlTextDidEndEditingNotification [self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]]; + if ([self sendsActionOnEndEditing]) + [self sendAction:[self action] to:[self target]]; + return YES; }