pub struct TimePickerState { /* private fields */ }Expand description
Owns one editable time, its input fields, selection wheels, and dialog session.
Implementations§
Source§impl TimePickerState
impl TimePickerState
Sourcepub fn new(
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
) -> TimePickerState
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.
Sourcepub fn segment(&self) -> TimePickerSegment
pub fn segment(&self) -> TimePickerSegment
Returns the currently active editing segment (TimePickerSegment::Hour or TimePickerSegment::Minute).
Sourcepub fn mode(&self) -> TimePickerVariant
pub fn mode(&self) -> TimePickerVariant
Returns the active editor mode (TimePickerVariant).
Sourcepub fn format(&self) -> TimeFormat
pub fn format(&self) -> TimeFormat
Returns the active 12-hour or 24-hour TimeFormat.
Sourcepub fn hour_input(&self, cx: &App) -> SharedString
pub fn hour_input(&self, cx: &App) -> SharedString
Returns the raw text currently in the hour input field.
Sourcepub fn minute_input(&self, cx: &App) -> SharedString
pub fn minute_input(&self, cx: &App) -> SharedString
Returns the raw text currently in the minute input field.
Sourcepub fn set_hour_input(
&mut self,
text: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn set_minute_input(
&mut self,
text: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn is_hour_input_valid(&self, cx: &App) -> bool
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.
Sourcepub fn is_minute_input_valid(&self, cx: &App) -> bool
pub fn is_minute_input_valid(&self, cx: &App) -> bool
Returns whether the minute input field currently parses as a valid minute (0–59).
Sourcepub fn is_input_valid(&self, cx: &App) -> bool
pub fn is_input_valid(&self, cx: &App) -> bool
Returns whether both hour and minute input fields currently contain valid values.
Sourcepub fn is_open(&self, cx: &App) -> bool
pub fn is_open(&self, cx: &App) -> bool
Returns whether the picker’s modal dialog is currently open.
Sourcepub fn trigger_focus(&self) -> &FocusHandle
pub fn trigger_focus(&self) -> &FocusHandle
Returns the retained focus handle of the built-in picker trigger.
Sourcepub fn set_value(
&mut self,
value: NaiveTime,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
pub fn set_value( &mut self, value: NaiveTime, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )
Replaces the editable draft and cancels outstanding wheel motion.
Sourcepub fn set_hour(
&mut self,
hour: u32,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
) -> bool
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.
Sourcepub fn set_minute(
&mut self,
minute: u32,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
) -> bool
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.
Sourcepub fn set_segment(
&mut self,
segment: TimePickerSegment,
cx: &mut Context<'_, TimePickerState>,
)
pub fn set_segment( &mut self, segment: TimePickerSegment, cx: &mut Context<'_, TimePickerState>, )
Switches the active editing segment between hours and minutes.
Sourcepub fn set_mode(
&mut self,
mode: TimePickerVariant,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn set_format(
&mut self,
format: TimeFormat,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn set_locale(
&mut self,
locale: TimePickerLocale,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn open(
&mut self,
value: NaiveTime,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
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.
Sourcepub fn close(
&mut self,
window: &mut Window,
cx: &mut Context<'_, TimePickerState>,
)
pub fn close( &mut self, window: &mut Window, cx: &mut Context<'_, TimePickerState>, )
Closes this session programmatically through the Material dialog.
Auto Trait Implementations§
impl !RefUnwindSafe for TimePickerState
impl !Send for TimePickerState
impl !Sync for TimePickerState
impl !UnwindSafe for TimePickerState
impl Forget for TimePickerState
impl Freeze for TimePickerState
impl Move for TimePickerState
impl Unpin for TimePickerState
impl UnsafeUnpin for TimePickerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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