pub struct DatePickerState { /* private fields */ }Expand description
A date picker’s state: selection, displayed month, view, mode and the
keyboard cursor. Create it once per picker with cx.new and hand it to
DatePicker.
Implementations§
Source§impl DatePickerState
impl DatePickerState
Sourcepub fn new(
labels: DatePickerLabels,
today: NaiveDate,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( labels: DatePickerLabels, today: NaiveDate, cx: &mut Context<'_, Self>, ) -> Self
A single-date picker showing today’s month, with nothing selected.
Sourcepub fn selection(self, selection: impl Into<DateSelection>) -> Self
pub fn selection(self, selection: impl Into<DateSelection>) -> Self
Start with selection, showing its (first) month.
Sourcepub fn disabled_dates(self, matcher: impl Into<DateMatcher>) -> Self
pub fn disabled_dates(self, matcher: impl Into<DateMatcher>) -> Self
Dates matching matcher cannot be selected.
Sourcepub fn years(self, years: RangeInclusive<i32>) -> Self
pub fn years(self, years: RangeInclusive<i32>) -> Self
The years the year grid and lists offer.
Sourcepub fn first_day_of_week(self, day: Weekday) -> Self
pub fn first_day_of_week(self, day: Weekday) -> Self
The weekday each grid row starts on (default Sunday).
Sourcepub fn view(self, view: DatePickerView) -> Self
pub fn view(self, view: DatePickerView) -> Self
Start in view (e.g. a specimen of the year grid).
Sourcepub fn input_mode(self) -> Self
pub fn input_mode(self) -> Self
Start in text-input mode.
Sourcepub fn with_inputs(
self,
start: Entity<InputState>,
end: Option<Entity<InputState>>,
cx: &mut Context<'_, Self>,
) -> Self
pub fn with_inputs( self, start: Entity<InputState>, end: Option<Entity<InputState>>, cx: &mut Context<'_, Self>, ) -> Self
Edit typed dates in these Kit inputs (the second for a range’s end).
The picker parses them with DatePickerLabels::parse_input.
pub fn labels(&self) -> &DatePickerLabels
pub fn focus_handle(&self) -> &FocusHandle
pub fn value(&self) -> DateSelection
pub fn today(&self) -> NaiveDate
Sourcepub fn displayed_month(&self) -> (i32, u32)
pub fn displayed_month(&self) -> (i32, u32)
The displayed (year, month).
pub fn current_view(&self) -> DatePickerView
pub fn mode(&self) -> DateInputMode
pub fn is_range(&self) -> bool
pub fn is_disabled(&self, date: NaiveDate) -> bool
Sourcepub fn set_value(
&mut self,
selection: DateSelection,
cx: &mut Context<'_, Self>,
)
pub fn set_value( &mut self, selection: DateSelection, cx: &mut Context<'_, Self>, )
Replace the selection without emitting.
Sourcepub fn select(&mut self, date: NaiveDate, cx: &mut Context<'_, Self>) -> bool
pub fn select(&mut self, date: NaiveDate, cx: &mut Context<'_, Self>) -> bool
Select date as a person would: a single picker replaces its date; a
range starts, completes (when date is not before the start) or
restarts, as in gpui_base::CalendarState::select_date. Disabled
dates are ignored. Returns whether the selection changed.
Sourcepub fn clear(&mut self, cx: &mut Context<'_, Self>)
pub fn clear(&mut self, cx: &mut Context<'_, Self>)
Clear the selection (keeping single or range).
Sourcepub fn show_month(&mut self, year: i32, month: u32, cx: &mut Context<'_, Self>)
pub fn show_month(&mut self, year: i32, month: u32, cx: &mut Context<'_, Self>)
Show year/month, sliding from the current month.
Months outside years show the nearest month inside them.
pub fn next_month(&mut self, cx: &mut Context<'_, Self>)
pub fn previous_month(&mut self, cx: &mut Context<'_, Self>)
pub fn next_year(&mut self, cx: &mut Context<'_, Self>)
pub fn previous_year(&mut self, cx: &mut Context<'_, Self>)
Sourcepub fn set_view(&mut self, view: DatePickerView, cx: &mut Context<'_, Self>)
pub fn set_view(&mut self, view: DatePickerView, cx: &mut Context<'_, Self>)
Switch the body between the day grid, the year grid/list and the docked month list.
Sourcepub fn toggle_view(&mut self, view: DatePickerView, cx: &mut Context<'_, Self>)
pub fn toggle_view(&mut self, view: DatePickerView, cx: &mut Context<'_, Self>)
Toggle view against the day grid.
Sourcepub fn choose_year(&mut self, year: i32, cx: &mut Context<'_, Self>)
pub fn choose_year(&mut self, year: i32, cx: &mut Context<'_, Self>)
Choose a year from the year grid or list and return to the days.
Sourcepub fn choose_month(&mut self, month: u32, cx: &mut Context<'_, Self>)
pub fn choose_month(&mut self, month: u32, cx: &mut Context<'_, Self>)
Choose a month from the docked list and return to the days.
Sourcepub fn toggle_mode(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn toggle_mode(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Switch between calendar and text input. Entering input mode writes the selection into the inputs; leaving it parses them.
Sourcepub fn parse_inputs(&mut self, cx: &mut Context<'_, Self>)
pub fn parse_inputs(&mut self, cx: &mut Context<'_, Self>)
Parse the text inputs into the selection. Invalid or disabled text marks its field invalid and leaves the selection unchanged.
Trait Implementations§
impl EventEmitter<DatePickerEvent> for DatePickerState
Auto Trait Implementations§
impl !RefUnwindSafe for DatePickerState
impl !Send for DatePickerState
impl !Sync for DatePickerState
impl !UnwindSafe for DatePickerState
impl Freeze for DatePickerState
impl Unpin for DatePickerState
impl UnsafeUnpin for DatePickerState
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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