pub struct TextField { /* private fields */ }Implementations§
Source§impl TextField
impl TextField
Sourcepub fn new<P: Into<Coord>>(
xy: P,
max_length: usize,
font: PixelFont,
size_limits: (Option<usize>, Option<usize>),
initial_content: &str,
filters: &[TextFilter],
style: &TextFieldStyle,
) -> Self
pub fn new<P: Into<Coord>>( xy: P, max_length: usize, font: PixelFont, size_limits: (Option<usize>, Option<usize>), initial_content: &str, filters: &[TextFilter], style: &TextFieldStyle, ) -> Self
UI element that allows text input Only supports characters in A-Z, a-z, 0-9, and some symbols a-z will be rendered as A-Z Does not support multiline
By default the width of the field is max_length * font width but this can be restricted/overridden using size_limits
§Params
xy- Coord of top left cornemax_length- Max number of charstext_size- Size of text, effects width and heightsize_limits- Optional min and optional max width of field in pixels (including border + padding)filters- Filter allowed key, if empty then defaults to All
Source§impl TextField
impl TextField
pub fn clear(&mut self)
pub fn set_content(&mut self, text: &str)
pub fn content(&self) -> &str
pub fn is_focused(&self) -> bool
pub fn unfocus(&mut self)
pub fn focus(&mut self)
pub fn is_full(&self) -> bool
pub fn on_mouse_click(&mut self, down: Coord, up: Coord) -> bool
pub fn on_mouse_drag(&mut self, down: Coord, up: Coord)
pub fn on_key_press(&mut self, key: KeyCode, held_keys: &FxHashSet<KeyCode>)
Trait Implementations§
Source§impl LayoutView for TextField
impl LayoutView for TextField
fn set_bounds(&mut self, bounds: Rect)
Auto Trait Implementations§
impl Freeze for TextField
impl RefUnwindSafe for TextField
impl Send for TextField
impl Sync for TextField
impl Unpin for TextField
impl UnwindSafe for TextField
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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.