Skip to content

Fix: draw a month and a clock in the calendar style - #861

Open
DTW-Thalion wants to merge 5 commits into
gnustep:masterfrom
DTW-Thalion:feature/datepicker-calendar
Open

Fix: draw a month and a clock in the calendar style#861
DTW-Thalion wants to merge 5 commits into
gnustep:masterfrom
DTW-Thalion:feature/datepicker-calendar

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

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

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.
@DTW-Thalion
DTW-Thalion requested a review from fredkiefer as a code owner July 29, 2026 20:45
START_SET creates an autorelease pool and END_SET releases it, so the pool
these tests create around the set is redundant.
@fredkiefer
fredkiefer removed their request for review September 6, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant