diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 21:25:42 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 21:25:42 +0000 |
commit | 98087a490d3c60557982d191e5bb9651edd0eb01 (patch) | |
tree | cffea1281bed268be7bcbc46f424a088b1f2fa73 /chrome/browser/cocoa/preferences_window_controller.mm | |
parent | 7b2b99405d3f5c413cae047291a8c75176f5850d (diff) | |
download | chromium_src-98087a490d3c60557982d191e5bb9651edd0eb01.zip chromium_src-98087a490d3c60557982d191e5bb9651edd0eb01.tar.gz chromium_src-98087a490d3c60557982d191e5bb9651edd0eb01.tar.bz2 |
Don't abandon or cancel in-progress field editors when the window closes.
BUG=17864
TEST=contents of fields are saved regardless of in-progress editing.
Review URL: http://codereview.chromium.org/174166
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/preferences_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 305ff24..372a4c6 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -231,9 +231,7 @@ class PrefObserverBridge : public NotificationObserver { context:context]; } -// Called when the user hits the escape key. Closes the window. This will -// automatically abandon/cancel any in-progress edits in text fields, we don't -// have to do anything special. +// Called when the user hits the escape key. Closes the window. - (void)cancel:(id)sender { [[self window] performClose:self]; } @@ -923,9 +921,18 @@ const int kDisabledIndex = 1; [self showWindow:sender]; } -// Called when the window is being closed. Send out a notification that the -// user is done editing preferences. +// Called when the window is being closed. Send out a notification that the user +// is done editing preferences. Make sure there are no pending field editors +// by clearing the first responder. - (void)windowWillClose:(NSNotification *)notification { + // Setting the first responder to the window ends any in-progress field + // editor. This will update the model appropriately so there's nothing left + // to do. + if (![[self window] makeFirstResponder:[self window]]) { + // We've hit a recalcitrant field editor, force it to go away. + [[self window] endEditingFor:nil]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:kUserDoneEditingPrefsNotification object:self]; |