Struct ambient_api::prelude::TextEditor
source · pub struct TextEditor {
pub value: String,
pub on_change: Arc<CbDebuggable<dyn Fn(String) + Sync + Send>>,
pub on_submit: Option<Arc<CbDebuggable<dyn Fn(String) + Sync + Send>>>,
pub password: bool,
pub placeholder: Option<String>,
pub auto_focus: bool,
}
Expand description
A text editor.
Fields§
§value: String
The string to edit.
on_change: Arc<CbDebuggable<dyn Fn(String) + Sync + Send>>
Callback for when the value is changed.
on_submit: Option<Arc<CbDebuggable<dyn Fn(String) + Sync + Send>>>
Callback for when the user presses enter.
password: bool
Whether the text should be obfuscated with ‘*’ characters.
placeholder: Option<String>
The placeholder text to display when the value is empty.
auto_focus: bool
Whether the text editor should be focused when it is created.
Implementations§
source§impl TextEditor
impl TextEditor
source§impl TextEditor
impl TextEditor
sourcepub fn new(
value: String,
on_change: Arc<CbDebuggable<dyn Fn(String) + Sync + Send>>
) -> TextEditor
pub fn new( value: String, on_change: Arc<CbDebuggable<dyn Fn(String) + Sync + Send>> ) -> TextEditor
Create a new text editor.
sourcepub fn on_submit(
self,
on_submit: impl Fn(String) + Sync + Send + 'static
) -> TextEditor
pub fn on_submit( self, on_submit: impl Fn(String) + Sync + Send + 'static ) -> TextEditor
Set the on_submit
callback.
sourcepub fn placeholder<T>(self, placeholder: Option<T>) -> TextEditor
pub fn placeholder<T>(self, placeholder: Option<T>) -> TextEditor
Set the placeholder text.
sourcepub fn password(self) -> TextEditor
pub fn password(self) -> TextEditor
Set whether or not the text should be hidden.
sourcepub fn auto_focus(self) -> TextEditor
pub fn auto_focus(self) -> TextEditor
Focus the text box automatically when it’s spawned.
Trait Implementations§
source§impl Clone for TextEditor
impl Clone for TextEditor
source§fn clone(&self) -> TextEditor
fn clone(&self) -> TextEditor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TextEditor
impl Debug for TextEditor
source§impl ElementComponent for TextEditor
impl ElementComponent for TextEditor
Auto Trait Implementations§
impl !RefUnwindSafe for TextEditor
impl Send for TextEditor
impl Sync for TextEditor
impl Unpin for TextEditor
impl !UnwindSafe for TextEditor
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> ElementComponentExt for Twhere
T: ElementComponent + 'static,
impl<T> ElementComponentExt for Twhere
T: ElementComponent + 'static,
source§impl<T> ElementComponentName for T
impl<T> ElementComponentName for T
source§fn element_component_name(&self) -> &'static str
fn element_component_name(&self) -> &'static str
Returns the name of the type implementing ElementComponent.