UI Toolbox logoUI Toolbox

TimePicker

A TimePicker is a BaseField<TimeSpan> for a time of day: a box with the hour, the minute and AM / PM, and a popup with one column for each part. For a duration, use TimeSpanPicker.

<UIToolbox.TimePicker label="Alarm" value="06:30" />
<UIToolbox.TimePicker label="Train" clock="Hours24" value="18:05" />
<UIToolbox.TimePicker label="Meeting" clock="Hours12" minute-increment="15" value="14:00" />
var picker = new TimePicker("Alarm") { value = new TimeSpan(6, 30, 0) };
picker.RegisterValueChangedCallback(evt => Debug.Log(evt.newValue));
Member Description
value The time of day, from 00:00 to 23:59. A set drops the days and the seconds. Listen with RegisterValueChangedCallback.
ValueText (value) The value as "hh:mm" on the 24-hour clock, such as "18:30". The picker ignores other text.
Clock (clock) Culture (the default), Hours12 or Hours24. Culture uses the 24-hour clock when the short time pattern of the culture has "H".
MinuteIncrement (minute-increment) The step of the minute column, from 1 (the default) to 30. 15 gives 00, 15, 30 and 45.
Culture The culture of the AM and PM texts and of the Culture clock. Null (the default) uses CultureInfo.CurrentCulture.
Is24Hour True when the picker shows hours 00 to 23 and no AM / PM.
IsOpen, Open(), Close(), Toggle() The state of the popup. Close() keeps the value.
Pending The time in the middle row of the popup columns.
Accept() Makes Pending the value and closes the popup.
Cancel() Closes the popup and keeps the value.

How to use it

Input Effect
A click on the box, Enter, Space or Down Opens the popup at the value.
A click on a row Moves that row to the middle. The middle row is the picked value of the column.
The mouse wheel on a column Steps the column one row.
Left and Right (the keys or the gamepad) Changes the active column. The active column has its middle row in the accent color.
Up and Down Steps the active column one row.
The ✓ button, Enter or the gamepad submit Accepts: the picked time becomes the value.
The ✕ button, Escape, the gamepad cancel or a click outside Closes the popup. The value stays.

Styling

Class Element
tb-time-picker The field.
tb-time-picker__box The box with the segments (150 px or more). It has the focus of the field.
tb-time-picker__segment The hour, the minute or the AM / PM text in the box.
tb-time-picker__segment--divided A segment with a line on its left: the minute and the AM / PM text.
tb-time-picker__popup The popup. It also has tb-popup.
tb-time-picker__columns The row of columns.
tb-time-picker__column One column. Each column is as wide as its segment.
tb-time-picker__column--active The column that Up and Down change.
tb-time-picker__row One row of a column (26 px high). A column has TimePicker.ROWS (7) rows.
tb-time-picker__row--selected The middle row.
tb-time-picker__footer The row with the buttons.
tb-time-picker__accept, tb-time-picker__cancel The ✓ and the ✕ button.