Skip to main content

TimePickerState

Struct TimePickerState 

Source
pub struct TimePickerState { /* private fields */ }
Expand description

Owns one editable time, its input fields, selection wheels, and dialog session.

Implementations§

Source§

impl TimePickerState

Source

pub fn new( window: &mut Window, cx: &mut Context<'_, TimePickerState>, ) -> TimePickerState

Creates a time picker state initialized to 00:00 in 24-hour dial mode.

Source

pub fn value(&self) -> NaiveTime

The latest valid draft, at minute precision.

Source

pub fn hour(&self) -> u32

Returns the draft hour in 24-hour format (0–23).

Source

pub fn minute(&self) -> u32

Returns the draft minute (0–59).

Source

pub fn is_pm(&self) -> bool

Returns true when the draft hour is 12 or later.

Source

pub fn segment(&self) -> TimePickerSegment

Returns the currently active editing segment (TimePickerSegment::Hour or TimePickerSegment::Minute).

Source

pub fn mode(&self) -> TimePickerVariant

Returns the active editor mode (TimePickerVariant).

Source

pub fn format(&self) -> TimeFormat

Returns the active 12-hour or 24-hour TimeFormat.

Source

pub fn hour_input(&self, cx: &App) -> SharedString

Returns the raw text currently in the hour input field.

Source

pub fn minute_input(&self, cx: &App) -> SharedString

Returns the raw text currently in the minute input field.

Source

pub fn set_hour_input( &mut self, text: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Replaces the text in the hour input field and updates the draft if valid.

Source

pub fn set_minute_input( &mut self, text: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Replaces the text in the minute input field and updates the draft if valid.

Source

pub fn is_hour_input_valid(&self, cx: &App) -> bool

Returns whether the hour input field currently parses as a valid hour for the active format.

Source

pub fn is_minute_input_valid(&self, cx: &App) -> bool

Returns whether the minute input field currently parses as a valid minute (0–59).

Source

pub fn is_input_valid(&self, cx: &App) -> bool

Returns whether both hour and minute input fields currently contain valid values.

Source

pub fn is_open(&self, cx: &App) -> bool

Returns whether the picker’s modal dialog is currently open.

Source

pub fn trigger_focus(&self) -> &FocusHandle

Returns the retained focus handle of the built-in picker trigger.

Source

pub fn set_value( &mut self, value: NaiveTime, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Replaces the editable draft and cancels outstanding wheel motion.

Source

pub fn set_hour( &mut self, hour: u32, window: &mut Window, cx: &mut Context<'_, TimePickerState>, ) -> bool

Sets a 24-hour value. Returns whether the supplied hour was valid.

Source

pub fn set_minute( &mut self, minute: u32, window: &mut Window, cx: &mut Context<'_, TimePickerState>, ) -> bool

Sets a minute in 0–59. Returns whether the supplied minute was valid.

Source

pub fn set_segment( &mut self, segment: TimePickerSegment, cx: &mut Context<'_, TimePickerState>, )

Switches the active editing segment between hours and minutes.

Source

pub fn set_mode( &mut self, mode: TimePickerVariant, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Retains the active segment across mode changes. Reconciles editors with the last valid time.

Source

pub fn set_format( &mut self, format: TimeFormat, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Switches between 12-hour and 24-hour display formats and resynchronizes editors and wheels.

Source

pub fn set_locale( &mut self, locale: TimePickerLocale, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Replaces the locale hooks and reformats the hour and minute input fields.

Source

pub fn open( &mut self, value: NaiveTime, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Opens a new editing session initialized from the application’s value.

Source

pub fn close( &mut self, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )

Closes this session programmatically through the Material dialog.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more