Merge branch 'refs/heads/slevenbits-popover-child-window-close-fix'

This commit is contained in:
Alexander Ljungberg committed 2013-03-12 17:02:57 +00:00
commit 921b30a892
3 files changed
+39 -1

No files matched your search

+16
View File
@@ -2453,6 +2453,22 @@ CPTexturedBackgroundWindowMask
return _parentWindow;
}
/*!
Return YES if anAncestor is the parent or a higher ancestor of the receiver.
@ignore
*/
- (BOOL)_hasAncestorWindow:(CPWindow)anAncestor
{
if (!_parentWindow || !anAncestor)
return NO;
if (anAncestor === _parentWindow)
return YES;
return [_parentWindow _hasAncestorWindow:anAncestor];
}
- (CPWindow)setParentWindow:(CPWindow)parentWindow
{
_parentWindow = parentWindow;
+3 -1
View File
@@ -569,7 +569,9 @@ var _CPPopoverWindow_shouldClose_ = 1 << 0,
var mouseWindow = [anEvent window];
if (mouseWindow === self)
// Consider clicks in child windows to be "inside". This keeps a transient popover from
// closing if e.g. the window containing the menu of a token field is clicked.
if (mouseWindow === self || [mouseWindow _hasAncestorWindow:self])
[self _trapNextMouseDown];
else
{
@@ -133,9 +133,29 @@ var STATES = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorad
[[self class] createTokenfieldContents:contentView withDelegate:self];
var popoverButton = [[CPButton alloc] initWithFrame:CGRectMake(15, 310, 0, 0)];
[popoverButton setTitle:"Token Field in a Popover"];
[popoverButton sizeToFit];
[popoverButton setTarget:self];
[popoverButton setAction:@selector(openPopover:)];
[contentView addSubview:popoverButton];
[theWindow orderFront:self];
}
- (@action)openPopover:(id)sender
{
var aPopover = [CPPopover new],
controller = [CPViewController new];
[aPopover setContentViewController:controller];
[aPopover setContentSize:CGSizeMake(800, 315)];
[[self class] createTokenfieldContents:[controller view] withDelegate:self];
[aPopover setAnimates:YES];
[aPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:CPMaxXEdge];
[aPopover setBehavior:CPPopoverBehaviorTransient];
}
- (CPArray)tokenField:(CPTokenField)aTokenField completionsForSubstring:(CPString)substring indexOfToken:(int)tokenIndex indexOfSelectedItem:(int)selectedIndex
{
var r = [];