Struct rat_widget::date_input::DateInputState
source · pub struct DateInputState {
pub widget: MaskedInputState,
pub non_exhaustive: NonExhaustive,
/* private fields */
}Expand description
State.
Use DateInputState::new(_pattern_) to set the date pattern.
Fields§
§widget: MaskedInputStateuses MaskedInputState for the actual functionality.
non_exhaustive: NonExhaustiveImplementations§
source§impl DateInputState
impl DateInputState
pub fn new<S: AsRef<str>>(pattern: S) -> Result<Self, Error>
pub fn new_loc<S: AsRef<str>>(pattern: S, locale: Locale) -> Result<Self, Error>
sourcepub fn set_format<S: AsRef<str>>(&mut self, pattern: S) -> Result<(), Error>
pub fn set_format<S: AsRef<str>>(&mut self, pattern: S) -> Result<(), Error>
chrono format string.
generates a mask according to the format and overwrites whatever set_mask() did.
sourcepub fn set_format_loc<S: AsRef<str>>(
&mut self,
pattern: S,
locale: Locale,
) -> Result<(), Error>
pub fn set_format_loc<S: AsRef<str>>( &mut self, pattern: S, locale: Locale, ) -> Result<(), Error>
chrono format string.
generates a mask according to the format and overwrites whatever set_mask() did.
sourcepub fn set_focused(&mut self, focus: bool)
pub fn set_focused(&mut self, focus: bool)
Renders the widget in focused style.
This flag is not used for event-handling.
sourcepub fn is_focused(&mut self) -> bool
pub fn is_focused(&mut self) -> bool
Renders the widget in focused style.
This flag is not used for event-handling.
sourcepub fn set_invalid(&mut self, invalid: bool)
pub fn set_invalid(&mut self, invalid: bool)
Renders the widget in invalid style.
sourcepub fn get_invalid(&self) -> bool
pub fn get_invalid(&self) -> bool
Renders the widget in invalid style.
sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Offset shown. This is corrected if the cursor wouldn’t be visible.
sourcepub fn set_cursor(&mut self, cursor: usize, extend_selection: bool) -> bool
pub fn set_cursor(&mut self, cursor: usize, extend_selection: bool) -> bool
Set the cursor position, reset selection.
sourcepub fn set_default_cursor(&mut self)
pub fn set_default_cursor(&mut self)
Place cursor at decimal separator, if any. 0 otherwise.
sourcepub fn default_value(&self) -> String
pub fn default_value(&self) -> String
Create a default value according to the mask.
sourcepub fn value(&self) -> Result<NaiveDate, ParseError>
pub fn value(&self) -> Result<NaiveDate, ParseError>
Parses the text according to the given pattern.
sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Selection
sourcepub fn set_selection(&mut self, anchor: usize, cursor: usize) -> bool
pub fn set_selection(&mut self, anchor: usize, cursor: usize) -> bool
Selection
sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text.
sourcepub fn selected_value(&self) -> &str
pub fn selected_value(&self) -> &str
Selection
sourcepub fn insert_char(&mut self, c: char) -> bool
pub fn insert_char(&mut self, c: char) -> bool
Insert a char at the current position.
sourcepub fn delete_range(&mut self, range: Range<usize>) -> bool
pub fn delete_range(&mut self, range: Range<usize>) -> bool
Remove the selected range. The text will be replaced with the default value as defined by the mask.
sourcepub fn delete_next_word(&mut self) -> bool
pub fn delete_next_word(&mut self) -> bool
Deletes the next word.
sourcepub fn delete_prev_word(&mut self) -> bool
pub fn delete_prev_word(&mut self) -> bool
Deletes the given range.
sourcepub fn delete_prev_char(&mut self) -> bool
pub fn delete_prev_char(&mut self) -> bool
Delete the char before the cursor.
sourcepub fn delete_next_char(&mut self) -> bool
pub fn delete_next_char(&mut self) -> bool
Delete the char after the cursor.
pub fn move_to_next_word(&mut self, extend_selection: bool) -> bool
pub fn move_to_prev_word(&mut self, extend_selection: bool) -> bool
sourcepub fn move_to_next(&mut self, extend_selection: bool) -> bool
pub fn move_to_next(&mut self, extend_selection: bool) -> bool
Move to the next char.
sourcepub fn move_to_prev(&mut self, extend_selection: bool) -> bool
pub fn move_to_prev(&mut self, extend_selection: bool) -> bool
Move to the previous char.
sourcepub fn move_to_line_start(&mut self, extend_selection: bool) -> bool
pub fn move_to_line_start(&mut self, extend_selection: bool) -> bool
Start of line
sourcepub fn move_to_line_end(&mut self, extend_selection: bool) -> bool
pub fn move_to_line_end(&mut self, extend_selection: bool) -> bool
End of line
sourcepub fn to_screen_col(&self, pos: usize) -> Option<u16>
pub fn to_screen_col(&self, pos: usize) -> Option<u16>
Converts a grapheme based position to a screen position relative to the widget area.
sourcepub fn from_screen_col(&self, x: usize) -> Option<usize>
pub fn from_screen_col(&self, x: usize) -> Option<usize>
Converts from a widget relative screen coordinate to a grapheme index. x is the relative screen position.
sourcepub fn set_screen_cursor(
&mut self,
cursor: isize,
extend_selection: bool,
) -> bool
pub fn set_screen_cursor( &mut self, cursor: isize, extend_selection: bool, ) -> bool
Set the cursor position from a screen position relative to the origin of the widget. This value can be negative, which selects a currently not visible position and scrolls to it.
sourcepub fn screen_cursor(&self) -> Option<(u16, u16)>
pub fn screen_cursor(&self) -> Option<(u16, u16)>
Screen position of the cursor for rendering.
Trait Implementations§
source§impl Clone for DateInputState
impl Clone for DateInputState
source§fn clone(&self) -> DateInputState
fn clone(&self) -> DateInputState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for DateInputState
impl Debug for DateInputState
source§impl Default for DateInputState
impl Default for DateInputState
source§impl HandleEvent<Event, ConvenientKeys, TextOutcome> for DateInputState
impl HandleEvent<Event, ConvenientKeys, TextOutcome> for DateInputState
source§fn handle(&mut self, event: &Event, _keymap: ConvenientKeys) -> TextOutcome
fn handle(&mut self, event: &Event, _keymap: ConvenientKeys) -> TextOutcome
source§impl HandleEvent<Event, FocusKeys, TextOutcome> for DateInputState
impl HandleEvent<Event, FocusKeys, TextOutcome> for DateInputState
source§impl HandleEvent<Event, MouseOnly, TextOutcome> for DateInputState
impl HandleEvent<Event, MouseOnly, TextOutcome> for DateInputState
source§impl HandleEvent<Event, ReadOnly, TextOutcome> for DateInputState
impl HandleEvent<Event, ReadOnly, TextOutcome> for DateInputState
source§impl HasFocusFlag for DateInputState
impl HasFocusFlag for DateInputState
source§fn z_areas(&self) -> &[ZRect]
fn z_areas(&self) -> &[ZRect]
source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Auto Trait Implementations§
impl !Freeze for DateInputState
impl !RefUnwindSafe for DateInputState
impl Send for DateInputState
impl !Sync for DateInputState
impl Unpin for DateInputState
impl UnwindSafe for DateInputState
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)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