Fix: draw a month and a clock in the calendar style - #861
Open
DTW-Thalion wants to merge 5 commits into
Open
Conversation
A date picker took no keys at all, so the date it held could only be changed in code. The pattern the cell shows is split into the parts the locale writes. The left and right arrow keys move between those parts, the up and down arrow keys step the part they are on, and a digit types into it. A step is a step of the calendar, so it carries into the parts above it, a day the next month is too short for moves back to that month's last day, and the result stays inside the minimum and maximum dates. A digit joins the digits already typed while the number they make can still grow, and is taken on its own once it cannot. The part being edited is drawn the way selected text is, while the picker holds the keyboard of a key window. An edit sends the action of the control. The delegate is asked to validate the proposed date, both for an edit and for a date set in code, and the date it hands back is the one the picker takes. NSDatePickerCell holds three more ivars, for the part being edited and for the digits typed into it.
A date picker could only be reached with the tab key, and the text field and stepper style drew no stepper. A click takes the keyboard and picks the part of the date under the pointer, so the arrow keys and the digits go to the part that was clicked. The style that asks for a stepper draws one at its trailing edge through the theme, keeps room for it in the cell size and in the text, and a click on its upper or lower half steps the part that is picked. A click that lands on no part is left to NSControl as before. The stepper does not repeat while the button is held.
GCC has no declaration of it in this file and takes the return value for an id, which does not compile.
The clock and calendar style drew the same line of text as the other styles, and asked for no more room than that line needs. It now draws the month the date falls in: a row for the name of the month and the year, a row for the initials of the weekdays and six weeks of days, with the day the picker holds marked the way selected text is. Beside it, when the time elements are asked for as well, it draws a clock face with an hour and a minute hand. The cell size covers what those need. A click picks the day under the pointer and keeps the time of day, and the arrow keys walk the grid in this style, a day across and a week up or down. Days of the months either side of this one are not drawn, and the clock is there to be read rather than set.
START_SET creates an autorelease pool and END_SET releases it, so the pool these tests create around the set is redundant.
fredkiefer
removed their request for review
September 6, 2026 15:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The clock and calendar style drew the same line of text as the other styles and asked for no more room than that line needs.
It now draws the month the date falls in: a row for the name of the month and the year, a row for the initials of the weekdays and six weeks of days, with the day the picker holds marked the way selected text is. Beside it, when the time elements are asked for as well, it draws a clock face with an hour and a minute hand, and the cell size covers what both need. A click picks the day under the pointer and keeps the time of day, and the arrow keys walk the grid in this style, a day across and a week up or down, which is what AppKit does with them.
Days of the months either side of this one are not drawn, and the clock is there to be read rather than set. The branch is cut off #860, which is cut off #859 and #858, and needs all three.
Tests/gui/NSDatePicker/calendar.m holds 9 assertions. It works out where a day sits from the size of the cell, so it holds whatever weekday the month starts on.
Refers to #95