pub struct Textbox { /* private fields */ }Expand description
Single-line text input method Allows navigating through the string, removing (using Backspace) and adding characters at the ‘_’ sign The cursor will hide the grapheme behind it
Design (including Border):
┌─────┐
│Tex_1│
└─────┘Implementations§
Source§impl Textbox
impl Textbox
pub const DELAY_DEFAULT: Duration
pub const CURSOR: Grapheme
pub const CURSOR_WIDE: Grapheme
pub fn default_callback(_: &mut Self)
pub fn default_key_handler(&mut self, event: &mut WindowEvent)
pub fn set_text_changed_callback<F: Fn(&mut Self) + 'static>( &mut self, callback: F, )
pub fn set_callback_delay(&mut self, duration: Duration)
pub fn set_key_handler(&mut self, f: TextboxKeyHandler)
Sourcepub fn set_cursor_type(&mut self, fat_cursor: bool)
pub fn set_cursor_type(&mut self, fat_cursor: bool)
fat_cursor: true will just highlight the current position, false will use _ instead
as cursor
Sourcepub fn set_focus_color(&mut self, focus_color: Option<Color>)
pub fn set_focus_color(&mut self, focus_color: Option<Color>)
Foreground color when the textbox has focus
pub fn is_readonly(&self) -> bool
pub fn set_readonly(&mut self, readonly: bool)
Sourcepub fn get_max_length(&self) -> usize
pub fn get_max_length(&self) -> usize
Returns the maximum length of the inner text
Sourcepub fn set_max_length(&mut self, length: usize)
pub fn set_max_length(&mut self, length: usize)
Sets the maximum length of the inner text (number of graphemes)
pub fn move_cursor_left(&mut self)
pub fn move_cursor_right(&mut self)
pub fn remove_glyph_before_cursor(&mut self)
pub fn insert_char_at_cursor(&mut self, ch: char)
Trait Implementations§
Source§impl HasWindowUID for Textbox
impl HasWindowUID for Textbox
Source§impl Widget for Textbox
impl Widget for Textbox
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
fn set_visibility(&mut self, visibility: bool)
fn set_width(&mut self, width: Size)
fn set_height(&mut self, _: Size)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
fn set_width_constraint(&mut self, width: SizeConstraint)
fn set_height_constraint(&mut self, _: SizeConstraint)
Source§impl WidgetColors for Textbox
impl WidgetColors for Textbox
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for Textbox
impl Window for Textbox
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§impl WindowLayout for Textbox
impl WindowLayout for Textbox
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnSource§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn margin(&self) -> Thickness
fn border(&self) -> BorderStyle
fn is_visible(&self) -> bool
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Auto Trait Implementations§
impl !RefUnwindSafe for Textbox
impl !Send for Textbox
impl !Sync for Textbox
impl !UnwindSafe for Textbox
impl Freeze for Textbox
impl Unpin for Textbox
impl UnsafeUnpin for Textbox
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property