ExpandingDatePicker for macOS

Apple uses a custom date picker control in their Calendar app that expands when it gets focus. I recreated it for my app and I’m sharing it on GitHub.

It looks like this…

Thankfully you can compose this from the stock date pickers in AppKit. It’s a textual date picker stacked on top of a graphical date picker. With some pretty chrome. And, shown in an NSPanel.

Usage

You can find it on GitHub at fpotter/ExpandingDatePicker.

Install it from from CocoaPods with pod 'ExpandingDatePicker'

But, the traffic lights go dark…

Yeah 🙁 You can see it in the demo above. Whenever the date picker expands, the host window’s traffic lights (close / minimize / full-screen buttons) will go dark. This does not happen in Calendar.app’s implementation of this control.

Why?

Whenever an NSWindow loses its key window status, traffic lights are darkened. That’s normal.

If we use Hopper and look at how Calendar.app opens its own panel, we find this in the private framework CalendarUI.framework:

Ahh! Apple uses a private NSWindow method addChildWindow:ordered:shareKey: whereas the public only has addChildWindow:ordered:. And, this shareKey parameter is the magic we need to let the host window keep its traffic lights lit.

If you’re not shipping in the App Store and don’t mind the private API usage, you might as well use it. See my notes in the source.