pub struct DatePickerState { /* private fields */ }Expand description
Coordinates one Calendar with one non-modal Popover in the same window.
Calendar exclusively owns the selected value, date arithmetic, and grid navigation. Popover exclusively owns opening, dismissal, and return focus. This composition resolves the current day focus immediately before opening and closes on single-date or completed-range activation. Multiple selection remains open until an explicit close or normal Popover dismissal.
Keep the matching DatePicker mounted while closed. Render the supplied calendar only inside this picker’s content, not in a second simultaneous Calendar. Opening focuses the first selected date, or the retained cursor when empty. Multiple selection retains its cursor if that date is selected.
Implementations§
Source§impl DatePickerState
impl DatePickerState
Sourcepub fn new(
calendar: &Entity<CalendarState>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( calendar: &Entity<CalendarState>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Uses an existing Calendar state, including its week start, disabled-date predicate, bounds, and initial value.
Sourcepub fn calendar(&self) -> &Entity<CalendarState>
pub fn calendar(&self) -> &Entity<CalendarState>
The shared date state used to render Calendar and its day/month controls.
pub fn selection<'a>(&self, cx: &'a App) -> &'a CalendarSelection
pub fn is_open(&self, cx: &App) -> bool
pub fn is_disabled(&self, cx: &App) -> bool
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The stable native Button trigger focus handle.
Sourcepub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Opens at the selection or retained cursor, using the Calendar focus policy.
Sourcepub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Closes without changing the value. Restores the trigger while the popup owns focus; outside/Tab dismissal retains the new focus target.
Sourcepub fn set_disabled(
&mut self,
disabled: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_disabled( &mut self, disabled: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Disables the trigger and calendar, closing an open popup first. Use this method to coordinate disabled state rather than changing the nested Calendar independently.
Sourcepub fn set_selection(
&mut self,
selection: CalendarSelection,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn set_selection( &mut self, selection: CalendarSelection, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Replaces the selection mode and value without emitting Change, closing an open popup first. Invalid, date-disabled, or out-of-bounds selections leave both states unchanged. An empty selection preserves the Calendar’s navigation date.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DatePickerState
impl !Send for DatePickerState
impl !Sync for DatePickerState
impl !UnwindSafe for DatePickerState
impl Forget for DatePickerState
impl Freeze for DatePickerStatewhere
NonZero<u32>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(CalendarState) -> CalendarState>: Freeze,
PhantomData<fn(PopoverState) -> PopoverState>: Freeze,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Freeze,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: Freeze,
*const dyn FnOnce() is !null: Freeze,
PhantomData<dyn FnOnce()>: Freeze,
impl Move for DatePickerState
impl Unpin for DatePickerState
impl UnsafeUnpin for DatePickerStatewhere
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(CalendarState) -> CalendarState>: UnsafeUnpin,
PhantomData<fn(PopoverState) -> PopoverState>: UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: UnsafeUnpin,
*const dyn FnOnce() is !null: UnsafeUnpin,
PhantomData<dyn FnOnce()>: UnsafeUnpin,
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