On Feb 24, 2013, at 6:33 AM, Graham Cox <graham....@bigpond.com> wrote:

> If you've done all that and it's still not working as expected, maybe there's 
> a subtle bug in the code that animates between the popover and the new 
> window. This being newish code, it's possible.

I've done all that, and I believe it is a bug. Now that I've found a 
workaround, I will report it to Apple.

> I have frequently found that Apple's own sample code isn't always as thorough 
> as it could be, so just using sample code as boilerplate may not have 
> considered all these issues; it might not be a bug but just something the 
> sample code didn't bother with.


Understood; that's my experience, too. Given the awkwardness of the workaround, 
however, it seems more likely that it is a bug.

Here's the workaround I came up with, tested in Apple's Popover example but not 
yet tested in my own application. Implement the -windowDidBecomeKey: delegate 
method in the main window's window controller, as follows:

- (void)windowDidBecomeKey:(NSNotification *)notification {
    if ([[notification object] isEqual:detachedWindow]) {
        // Disable delegates to avoid infinite loop.
        [[self window] setDelegate:nil];
        [[notification object] setDelegate:nil];
        
        // Make main window key, then make detached popover window key.
        [[self window] performSelector:@selector(makeKeyAndOrderFront:) 
withObject:nil afterDelay:0.0];
        [[notification object] performSelector:@selector(makeKeyAndOrderFront:) 
withObject:nil afterDelay:0.0];

        // Re-enable delegates.
        [[self window] performSelector:@selector(setDelegate:) withObject:(id 
<NSWindowDelegate>)self afterDelay:0.0];
        [[notification object] performSelector:@selector(setDelegate:) 
withObject:self afterDelay:0.0];
}

If you want to test this yourself in the Popover example, be sure to connect 
the delegate attribute of the popover window in MainMenu.xib to 
MyWindowController, and add a date picker to the view in PopoverView.xib.

-- 

Bill Cheeseman - b...@cheeseman.name

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to