From e3d0d6991855008c124af913d5d4f98d24110968 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Tue, 14 Aug 2012 22:43:01 +0100 Subject: [PATCH] Refs #1364. Avoid repeated makeFirstResponder: calls within sheet parent. If a window contained a text field which was the initial first responder, and the window was displaying a sheet, clicking on the window would cause the text field to alternate between being the first responder and not. This was caused by the window `orderFront:` setting its first responder to the initial responder if there wasn't any responder yet. This would cause the text field to focus, even that the window wasn't the key window, and then on the next click the text field would blur which would make the text field automatically resign its first responder status. The solution is to leave the first responder status alone if a window which isn't the key window is `orderFront:`ed. This appears to be more sensible UX in general. You don't expect the first responder of non-key windows to change when you click it's background. --- AppKit/CPWindow/CPWindow.j | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index f3b93531f..6991f5781 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -857,12 +857,12 @@ CPTexturedBackgroundWindowMask [_platformWindow order:CPWindowAbove window:self relativeTo:nil]; #endif - if (_firstResponder === self || !_firstResponder) - [self makeFirstResponder:_initialFirstResponder]; - if (!CPApp._keyWindow) [self makeKeyWindow]; + if ([self isKeyWindow] && (_firstResponder === self || !_firstResponder)) + [self makeFirstResponder:_initialFirstResponder]; + if (!CPApp._mainWindow) [self makeMainWindow]; }