pub struct TextEditorArgs {Show 15 fields
pub width: DimensionValue,
pub height: DimensionValue,
pub on_change: Arc<dyn Fn(String) -> String + Send + Sync>,
pub min_width: Option<Dp>,
pub min_height: Option<Dp>,
pub background_color: Option<Color>,
pub border_width: Dp,
pub border_color: Option<Color>,
pub shape: Shape,
pub padding: Dp,
pub focus_border_color: Option<Color>,
pub focus_background_color: Option<Color>,
pub selection_color: Option<Color>,
pub accessibility_label: Option<String>,
pub accessibility_description: Option<String>,
}Expand description
Arguments for configuring the text_editor component.
Fields§
§width: DimensionValueWidth constraint for the text editor. Defaults to Wrap.
height: DimensionValueHeight constraint for the text editor. Defaults to Wrap.
on_change: Arc<dyn Fn(String) -> String + Send + Sync>Called when the text content changes. The closure receives the new text content and returns the updated content.
min_width: Option<Dp>Minimum width in density-independent pixels. Defaults to 120dp if not specified.
min_height: Option<Dp>Minimum height in density-independent pixels. Defaults to line height + padding if not specified.
background_color: Option<Color>Background color of the text editor (RGBA). Defaults to light gray.
border_width: DpBorder width in Dp. Defaults to 1.0 Dp.
border_color: Option<Color>Border color (RGBA). Defaults to gray.
shape: ShapeThe shape of the text editor container.
padding: DpPadding inside the text editor. Defaults to 5.0 Dp.
focus_border_color: Option<Color>Border color when focused (RGBA). Defaults to blue.
focus_background_color: Option<Color>Background color when focused (RGBA). Defaults to white.
selection_color: Option<Color>Color for text selection highlight (RGBA). Defaults to light blue with transparency.
accessibility_label: Option<String>Optional label announced by assistive technologies.
accessibility_description: Option<String>Optional description announced by assistive technologies.
Implementations§
Source§impl TextEditorArgs
Convenience constructors for common use cases
impl TextEditorArgs
Convenience constructors for common use cases
Sourcepub fn simple() -> Self
pub fn simple() -> Self
Creates a simple text editor with default styling.
- Minimum width: 120dp
- Background: white
- Border: 1px gray, rounded rectangle
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple();Source§impl TextEditorArgs
Builder methods for fluent API
impl TextEditorArgs
Builder methods for fluent API
Sourcepub fn with_width(self, width: DimensionValue) -> Self
pub fn with_width(self, width: DimensionValue) -> Self
Sets the width constraint for the editor.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_width(DimensionValue::Fixed(Px(200)));Sourcepub fn with_height(self, height: DimensionValue) -> Self
pub fn with_height(self, height: DimensionValue) -> Self
Sets the height constraint for the editor.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_height(DimensionValue::Fixed(Px(100)));Sourcepub fn with_min_width(self, min_width: Dp) -> Self
pub fn with_min_width(self, min_width: Dp) -> Self
Sets the minimum width in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_width(Dp(80.0));Sourcepub fn with_min_height(self, min_height: Dp) -> Self
pub fn with_min_height(self, min_height: Dp) -> Self
Sets the minimum height in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_height(Dp(40.0));Sourcepub fn with_background_color(self, color: Color) -> Self
pub fn with_background_color(self, color: Color) -> Self
Sets the background color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_background_color(Color::WHITE);Sourcepub fn with_border_width(self, width: Dp) -> Self
pub fn with_border_width(self, width: Dp) -> Self
Sets the border width in pixels.
§Example
use tessera_ui::Dp;
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple().with_border_width(Dp(1.0));Sourcepub fn with_border_color(self, color: Color) -> Self
pub fn with_border_color(self, color: Color) -> Self
Sets the border color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_border_color(Color::BLACK);Sourcepub fn with_shape(self, shape: Shape) -> Self
pub fn with_shape(self, shape: Shape) -> Self
Sets the shape of the editor container.
§Example
use tessera_ui::Dp;
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui_basic_components::shape_def::{RoundedCorner, Shape};
let args = TextEditorArgs::simple().with_shape(Shape::RoundedRectangle {
top_left: RoundedCorner::manual(Dp(8.0), 3.0),
top_right: RoundedCorner::manual(Dp(8.0), 3.0),
bottom_right: RoundedCorner::manual(Dp(8.0), 3.0),
bottom_left: RoundedCorner::manual(Dp(8.0), 3.0),
});Sourcepub fn with_padding(self, padding: Dp) -> Self
pub fn with_padding(self, padding: Dp) -> Self
Sets the inner padding in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_padding(Dp(12.0));Sourcepub fn with_focus_border_color(self, color: Color) -> Self
pub fn with_focus_border_color(self, color: Color) -> Self
Sets the border color when focused.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_border_color(Color::new(0.0, 0.5, 1.0, 1.0));Sourcepub fn with_focus_background_color(self, color: Color) -> Self
pub fn with_focus_background_color(self, color: Color) -> Self
Sets the background color when focused.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_background_color(Color::WHITE);Sourcepub fn with_selection_color(self, color: Color) -> Self
pub fn with_selection_color(self, color: Color) -> Self
Sets the selection highlight color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_selection_color(Color::new(0.5, 0.7, 1.0, 0.4));Trait Implementations§
Source§impl Clone for TextEditorArgs
impl Clone for TextEditorArgs
Source§fn clone(&self) -> TextEditorArgs
fn clone(&self) -> TextEditorArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TextEditorArgs
impl !RefUnwindSafe for TextEditorArgs
impl Send for TextEditorArgs
impl Sync for TextEditorArgs
impl Unpin for TextEditorArgs
impl !UnwindSafe for TextEditorArgs
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().