Skip to main content

Module date_edit

Module date_edit 

Source
Expand description

DateEdit — text input + calendar popover, bound to Signal<Option<Date>>.

A single-line editable date field. The underlying surface is a TextInputField displaying the formatted date; commit on Enter or blur parses the input against the active pattern, clamps to [min_date, max_date], and writes the result back. A trailing calendar-icon button opens a Calendar popover anchored below the field for graphical date selection.

§Behaviour

  • Value binding: Signal<Option<Date>> is the source of truth. External writes re-format the text. None shows the placeholder.
  • Pattern: locale-derived strftime-subset (%Y-%m-%d, %m/%d/%Y, …); override via format_pattern.
  • Step keys (preview-pass on the field): the step is segment-relative — it moves the field under the caret (year, month or day), which is what QDateTimeEdit does.
    • Arrow Up / Down → ±1 unit of that segment; Shift+ → ±10.
    • Page Up / Page Down → ±10 units; Shift+ → ±100.
    • Alt+ArrowDown (or click the calendar icon) → opens the calendar popover; Alt+ArrowUp closes it and F4 toggles it.
    • A chord holding Ctrl or Super is not the field’s and falls through to the application.
  • Calendar popover: dismisses on click-outside or Escape, commits on cell click. The request carries no fade_duration, so it appears and goes without a fade.
  • Min / Max: clamps on commit and on step. Out-of-range values in the popover cell are disabled.

§Accessibility

  • Container: Role::DateInput, named from the .label() builder, its value the selected day in full in the tree’s locale (“samedi 2 mai 2026”, “Saturday, May 2, 2026”), and set_placeholder when the value is None. The field inside shows the editable pattern; this value is written for someone listening, not for a parser. UIA and macOS expose it; AT-SPI carries a string value on no interface.
  • Calendar trigger button — Role::Button, named from its tooltip. set_has_popup(HasPopup::Grid) and set_expanded(open) sit on the container node above, not on the button.
  • Internally the editing surface remains a Role::TextInput for AT discoverability (so screen readers know it accepts text); the wrapper carries the DateInput role on the outer node. The field is where focus lands, so it carries the same name, and it is the composite’s accessibility_proxy: an access_label or an access_described_by given to the DateEdit lands on the field. A labelled_by relation (a FormLayout row’s) lands there too, but AccessKit reads a node’s own name before its relations, so name a date field in a form with .label().
  • The calendar opens on the date the field holds (the text typed in it is committed first), on its days, whatever an earlier opening left.

§Example

ⓘ
use teksilo::widgets::{DateEdit, common::datetime::Date};

let date = ctx.signal(Some(Date::constant(2026, 5, 2)));
ctx.add(
    DateEdit::new(date.clone())
        .min_date(Date::constant(2020, 1, 1))
        .max_date(Date::constant(2030, 12, 31))
        .label(lit!("Birth date")),
);

§Touch and pen

Nothing to declare here, and the reason applies to the whole date/time family (TimeEdit, DateTimeEdit, DateRangeEdit): the composite’s own handler set carries focus_within and on_key_preview only — no tap, no drag, no scroll — so its pointer surface is entirely the embedded text field, the trigger IconButton and the popover Calendar, each of which answers for itself. In particular the family does not declare touch_action(NONE): it produces no value from a press position, and declaring it would stop a finger scrolling a form that contains a date field.

Structs§

DateEdit
Single-line date input with optional calendar popover. See the module docs for the full feature list.

Enums§

ValidationBehavior
How the date editor reacts to out-of-range or partially invalid input.
WidthPolicy
How a datetime widget claims horizontal space.