0

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

Craig Otis
  • 31,257
  • 32
  • 136
  • 234
  • 1
    I noticed that when going to another month and then clicking on any day followed by either `today` or `tomorrow` that it jumps back properly. So it seems that it already knows it's on today or tomorrow, but the view needs to be notified to jump back. – l'L'l Jan 04 '14 at 18:14
  • @l'L'l Yea, exactly. The problem is there *isn't a way* to notify the view to jump back. – Craig Otis Jan 04 '14 at 18:25
  • It might be possible to have the today or tomorrow button select the first day of whichever month you're viewing first so it jumps back, although seems like a silly thing to have to do. – l'L'l Jan 04 '14 at 18:34

1 Answers1

2

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.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135
  • Bug filed - I also tried `setNeedsDisplay:YES` with no success. I will fiddle with the min/max methods this afternoon. – Craig Otis Jan 04 '14 at 18:31