pub struct DatePickerState { /* private fields */ }Expand description
Owns the Base calendar, input editors, and draft focus. The application owns the value passed to the picker. Every open copies that value into the draft.
Implementations§
Source§impl DatePickerState
impl DatePickerState
Sourcepub fn new(
window: &mut Window,
cx: &mut Context<'_, DatePickerState>,
) -> DatePickerState
pub fn new( window: &mut Window, cx: &mut Context<'_, DatePickerState>, ) -> DatePickerState
Creates a new date picker state with default bounds (1900-01-01 through 2100-12-31).
Sourcepub fn date_bounds(self, bounds: RangeInclusive<NaiveDate>) -> DatePickerState
pub fn date_bounds(self, bounds: RangeInclusive<NaiveDate>) -> DatePickerState
Restricts the displayed months and selectable dates. A reversed range is ordered before it is applied on the next open.
Sourcepub fn disabled_dates(
self,
disabled: impl Fn(NaiveDate) -> bool + Send + Sync + 'static,
) -> DatePickerState
pub fn disabled_dates( self, disabled: impl Fn(NaiveDate) -> bool + Send + Sync + 'static, ) -> DatePickerState
Disables individual days and range endpoints.
Sourcepub fn initial_month(self, date: NaiveDate) -> DatePickerState
pub fn initial_month(self, date: NaiveDate) -> DatePickerState
Selects which month is initially displayed on each open.
Sourcepub fn disabled_years(
self,
disabled: impl Fn(i32) -> bool + Send + Sync + 'static,
) -> DatePickerState
pub fn disabled_years( self, disabled: impl Fn(i32) -> bool + Send + Sync + 'static, ) -> DatePickerState
Marks every date in matching years unavailable, independently of day filtering.
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 is_open(&self, cx: &App) -> bool
pub fn is_open(&self, cx: &App) -> bool
Returns whether the docked popup or modal dialog is currently open.
Sourcepub fn last_close_reason(&self, cx: &App) -> Option<DialogCloseReason>
pub fn last_close_reason(&self, cx: &App) -> Option<DialogCloseReason>
Returns the reason the picker was most recently closed, if any.
Sourcepub fn set_displayed_month(
&mut self,
date: NaiveDate,
cx: &mut Context<'_, DatePickerState>,
)
pub fn set_displayed_month( &mut self, date: NaiveDate, cx: &mut Context<'_, DatePickerState>, )
Updates presentation and cursor without changing the draft.
Sourcepub fn displayed_month(&self) -> NaiveDate
pub fn displayed_month(&self) -> NaiveDate
Returns the first day of the month currently shown by the calendar cursor.
Sourcepub fn draft(&self, cx: &App) -> DatePickerDraft
pub fn draft(&self, cx: &App) -> DatePickerDraft
Reads the current in-progress draft from the active display mode.
Sourcepub fn input_editors(
&self,
cx: &App,
) -> (&Entity<InputBaseState<InputMode>>, Option<&Entity<InputBaseState<InputMode>>>)
pub fn input_editors( &self, cx: &App, ) -> (&Entity<InputBaseState<InputMode>>, Option<&Entity<InputBaseState<InputMode>>>)
Returns the retained start editor and the end editor for a range draft.
Sourcepub fn set_draft(
&mut self,
draft: DatePickerDraft,
window: &mut Window,
cx: &mut Context<'_, DatePickerState>,
) -> bool
pub fn set_draft( &mut self, draft: DatePickerDraft, window: &mut Window, cx: &mut Context<'_, DatePickerState>, ) -> bool
Applies a valid draft, including empty values and a range with only a start.
Sourcepub fn display_mode(&self) -> DatePickerDisplayMode
pub fn display_mode(&self) -> DatePickerDisplayMode
Returns the active display mode (Calendar or Input).
Sourcepub fn set_display_mode(
&mut self,
mode: DatePickerDisplayMode,
window: &mut Window,
cx: &mut Context<'_, DatePickerState>,
) -> bool
pub fn set_display_mode( &mut self, mode: DatePickerDisplayMode, window: &mut Window, cx: &mut Context<'_, DatePickerState>, ) -> bool
Changes display mode after any active IME composition has finished.
Sourcepub fn open(
&mut self,
value: DateSelection,
variant: DatePickerVariant,
locale: &DatePickerLocale,
window: &mut Window,
cx: &mut Context<'_, DatePickerState>,
)
pub fn open( &mut self, value: DateSelection, variant: DatePickerVariant, locale: &DatePickerLocale, window: &mut Window, cx: &mut Context<'_, DatePickerState>, )
Opens a picker rendered by a caller-owned trigger and copies the committed value.
Sourcepub fn close(
&mut self,
window: &mut Window,
cx: &mut Context<'_, DatePickerState>,
)
pub fn close( &mut self, window: &mut Window, cx: &mut Context<'_, DatePickerState>, )
Closes either presentation and restores focus when the picker still owns it.
Auto Trait Implementations§
impl !Freeze for DatePickerState
impl !RefUnwindSafe for DatePickerState
impl !Send for DatePickerState
impl !Sync for DatePickerState
impl !UnwindSafe for DatePickerState
impl Forget for DatePickerState
impl Move for DatePickerState
impl Unpin for DatePickerState
impl UnsafeUnpin for DatePickerState
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