• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with NSDatePicker in popover (workaround)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSDatePicker in popover (workaround)


  • Subject: Re: Problem with NSDatePicker in popover (workaround)
  • From: "William J. Cheeseman" <email@hidden>
  • Date: Sun, 24 Feb 2013 08:04:47 -0500

On Feb 24, 2013, at 6:33 AM, Graham Cox <email@hidden> 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 - email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem with NSDatePicker in popover (workaround)
      • From: "William J. Cheeseman" <email@hidden>
    • Re: Problem with NSDatePicker in popover (workaround)
      • From: "William J. Cheeseman" <email@hidden>
References: 
 >Problem with NSDatePicker in popover (From: "William J. Cheeseman" <email@hidden>)
 >Re: Problem with NSDatePicker in popover (From: "William J. Cheeseman" <email@hidden>)
 >Re: Problem with NSDatePicker in popover (From: "William J. Cheeseman" <email@hidden>)
 >Re: Problem with NSDatePicker in popover (From: "William J. Cheeseman" <email@hidden>)
 >Re: Problem with NSDatePicker in popover (From: Graham Cox <email@hidden>)
 >Re: Problem with NSDatePicker in popover (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSSavePanel problem
  • Next by Date: Interpreting glyph layout exception
  • Previous by thread: Re: Problem with NSDatePicker in popover
  • Next by thread: Re: Problem with NSDatePicker in popover (workaround)
  • Index(es):
    • Date
    • Thread