NSDatePicker failing to refresh when setting date to current date

240 views Asked by At

I have an NSDatePicker with an associated NSButton that changes the current date to "Today" when pressed.

However: When the date is currently January 4th, 2014, and I use the built-in arrow buttons to switch to a different month without changing the actual selected date, there seems to be no way to get the calendar to refresh. Here's a video of the issue:

Video of the Issue: https://www.dropbox.com/s/ay7fljnoyxb06ua/Calendar%20Test%20Video.mov

See the attached sample project for an example. To reproduce:

  1. Click "Today"
  2. Click the right-arrow button to switch to a different month (without selecting an actual day)
  3. Click "Today"

The NSDatePicker seems to fail to refresh if you're programmatically selecting a date that is not in the currently-viewed month, and if the date that it is switching from is in a different month as well.

But, the date is properly picked. If you use the buttons to select a date, then manually browse back to the proper month, the date has been selected. But the calendar never shows you that month automatically, unless the date you're switching from is in the currently-viewed month.

Sample Project: https://www.dropbox.com/s/tnpox2mt5f5z2nb/CalendarTest.zip

1

There are 1 answers

1
Joshua Nozzi On

I would file this as a bug against the API since there are no methods in the class that suggest you'd have to ask it to refresh manually (I'd assume setting the selected date would automatically display the proper range to show that selection).

As a work-around, you might try asking it to display ( -setNeedsDisplay:YES ) or manually twiddling its min/max range after setting the date, then setting it back to unlimited immediately after. Maybe that'll kick-start it into displaying the correct range for the selected date.