mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-11 05:07:13 +00:00
Fixed: token field autocomplete menu remaining after window closed.
Without this change, closing the window containing a token field showing an autocomplete menu would result in a detached autocomplete menu hanging around. This fix checks for window close notifications and makes sure to dismiss the menu if the window closes.
This commit is contained in:
@@ -651,6 +651,9 @@ var CPViewFlags = { },
|
||||
if (_window === aWindow)
|
||||
return;
|
||||
|
||||
// Unlike in Cocoa you can observe the window of a view.
|
||||
[self willChangeValueForKey:@"window"];
|
||||
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
// Clear out first responder if we're the first responder and leaving.
|
||||
@@ -678,6 +681,8 @@ var CPViewFlags = { },
|
||||
[self viewDidMoveToWindow];
|
||||
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
[self didChangeValueForKey:@"window"];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -38,6 +38,7 @@ var _CPAutocompleteMenuMaximumHeight = 307;
|
||||
float widestItemWidth;
|
||||
|
||||
CPWindow _menuWindow;
|
||||
CPWindow _parentWindow @accessors(property=parentWindow);
|
||||
CPScrollView scrollView;
|
||||
CPTableView tableView;
|
||||
|
||||
@@ -48,7 +49,8 @@ var _CPAutocompleteMenuMaximumHeight = 307;
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
textField = aTextField;
|
||||
[self bind:@"parentWindow" toObject:self withKeyPath:@"textField.window" options:nil];
|
||||
[self setTextField:aTextField];
|
||||
|
||||
_menuWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 100, 100) styleMask:CPBorderlessWindowMask];
|
||||
|
||||
@@ -258,6 +260,25 @@ var _CPAutocompleteMenuMaximumHeight = 307;
|
||||
[textField _complete:self];
|
||||
}
|
||||
|
||||
- (void)setParentWindow:(CPWindow)aWindow
|
||||
{
|
||||
if (aWindow === _parentWindow)
|
||||
return;
|
||||
|
||||
if (_parentWindow)
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
_parentWindow = aWindow;
|
||||
|
||||
if (_parentWindow)
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(parentWindowWillClose:) name:CPWindowWillCloseNotification object:_parentWindow];
|
||||
}
|
||||
|
||||
- (void)parentWindowWillClose:(CPNotification)aNotification
|
||||
{
|
||||
[self _hideCompletions];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user