From 2236e7d2dacae05d2691818f1fc67947718be57a Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 26 Nov 2012 13:48:45 +0000 Subject: [PATCH 1/3] Unused variable. --- AppKit/CPTokenField.j | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 0fc6391f7..b7b8824ba 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -988,8 +988,7 @@ var CPScrollDestinationNone = 0, var frame = [self frame], contentView = [_tokenScrollView documentView], - tokens = [self _tokens], - shouldShowAutoComplete = [self hasThemeState:CPThemeStateAutocompleting]; + tokens = [self _tokens]; // Hack to make sure we are handling an array if (![tokens isKindOfClass:[CPArray class]]) From ce9534cdea764fcc674fce830742636dd81588ec Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 26 Nov 2012 14:01:33 +0000 Subject: [PATCH 2/3] Fixed: canBecomeKeyWindow response for auxiliary windows. Without this fix Cappuccino always returned YES for `canBecomeKeyWindow` for every window. But in Cocoa, only "standard" windows with a title bar and/or resizing return YES. With this fix Cappuccino better matches Cocoa's behaviour. --- AppKit/CPWindow/CPWindow.j | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 01bf60f10..c1e14a813 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1856,7 +1856,9 @@ CPTexturedBackgroundWindowMask */ - (BOOL)canBecomeKeyWindow { - return YES; + // In Cocoa only resizable or titled windows return YES here by default. But the main browser window in Cappuccino + // doesn't have these masks even that it's both titled and resizable, so we return YES when isFullPlatformWindow too. + return (_styleMask & CPResizableWindowMask) || (_styleMask & CPResizableWindowMask) || [self isFullPlatformWindow]; } /*! From 9d4e8164b7cced0004193bae7d2c75af9c545a19 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 26 Nov 2012 15:39:41 +0000 Subject: [PATCH 3/3] Fixed: token field autocomplete selection by mouse. After recent changes clicking on an autocomplete item in the pop up did nothing. Now this works and in conjunction with the new non-key-window-change update it's likely to work better than before. --- AppKit/CPTokenField.j | 14 +++++++++++--- AppKit/_CPAutocompleteMenu.j | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index b7b8824ba..c223e6c4a 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -138,6 +138,11 @@ var CPScrollDestinationNone = 0, return _autocompleteMenu; } +- (void)_complete:(_CPAutocompleteMenu)anAutocompleteMenu +{ + [self _autocompleteWithEvent:nil]; +} + - (void)_autocompleteWithEvent:(CPEvent)anEvent { if (![self _inputElement].value && (![_autocompleteMenu contentArray] || ![self hasThemeState:CPThemeStateAutocompleting])) @@ -647,10 +652,13 @@ var CPScrollDestinationNone = 0, if (CPTokenFieldInputOwner && CPTokenFieldInputOwner._preventResign) return false; - if (!CPTokenFieldInputResigning && !CPTokenFieldFocusInput) + if (!CPTokenFieldInputResigning && [[CPTokenFieldInputOwner window] isKeyWindow]) { - [[CPTokenFieldInputOwner window] makeFirstResponder:nil]; - return; + // If we lost focus somehow but we're not resigning and we're still in the key window, we'll need to take it back. + window.setTimeout(function() + { + CPTokenFieldDOMInputElement.focus(); + }, 0.0); } CPTokenFieldHandleBlur(anEvent, CPTokenFieldDOMInputElement); diff --git a/AppKit/_CPAutocompleteMenu.j b/AppKit/_CPAutocompleteMenu.j index 78d1be533..f0cbc3fe0 100644 --- a/AppKit/_CPAutocompleteMenu.j +++ b/AppKit/_CPAutocompleteMenu.j @@ -73,6 +73,8 @@ var _CPAutocompleteMenuMaximumHeight = 307; [tableView setDataSource:self]; [tableView setDelegate:self]; + [tableView setTarget:self]; + [tableView setAction:@selector(complete:)]; [tableView setAllowsMultipleSelection:NO]; [tableView setHeaderView:nil]; [tableView setCornerView:nil]; @@ -251,6 +253,11 @@ var _CPAutocompleteMenuMaximumHeight = 307; return [contentArray objectAtIndex:row]; } +- (@action)complete:(id)sender +{ + [textField _complete:self]; +} + @end