pub struct TextInput { /* private fields */ }Expand description
A one-line text field. It takes the keyboard focus when clicked, when
Tab reaches it, or when focus says so, and edits the
text in a shared signal: typing writes it, and setting it changes what
the field shows. Arrows, Home and End move the caret, Shift selects,
Ctrl moves and deletes by word, and Ctrl+A selects everything. Keys it
doesn’t use, such as Up, Down and Escape, go on to the window’s
on_key.
use crabshell_ui::{Cx, TextInput};
fn search(cx: &Cx) -> TextInput {
let query = cx.signal(String::new());
TextInput::new(query)
.placeholder("Search")
.on_accept(|_cx, text| println!("run {text}"))
}Implementations§
Source§impl TextInput
impl TextInput
Sourcepub fn placeholder(self, text: impl IntoProp<String>) -> TextInput
pub fn placeholder(self, text: impl IntoProp<String>) -> TextInput
Sets the text shown, dimmed, while the field is empty.
Sourcepub fn password(self, password: impl IntoProp<bool>) -> TextInput
pub fn password(self, password: impl IntoProp<bool>) -> TextInput
Sets whether the field shows a dot for each character instead of the text.
Sourcepub fn focus(self, focus: impl IntoProp<bool>) -> TextInput
pub fn focus(self, focus: impl IntoProp<bool>) -> TextInput
Takes the keyboard focus whenever this turns true, as when a launcher opens.
Trait Implementations§
Source§impl Widget for TextInput
impl Widget for TextInput
Source§fn into_element(self: Box<Self>) -> Element
fn into_element(self: Box<Self>) -> Element
Turns the description, and everything inside it, into the element
the window builds nodes from. It runs when the window is created or a
list item first appears, before the window’s tree is touched and
without recording what it reads, so it only describes.
Auto Trait Implementations§
impl !RefUnwindSafe for TextInput
impl !Send for TextInput
impl !Sync for TextInput
impl !UnwindSafe for TextInput
impl Forget for TextInput
impl Freeze for TextInput
impl Move for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
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