Skip to main content

TextArea

Struct TextArea 

Source
pub struct TextArea {
    pub value: String,
    pub placeholder: String,
    pub focused: bool,
    pub width: Option<f32>,
    pub height: f32,
    pub font_size: Option<f32>,
    pub radius: f32,
    /* private fields */
}
Expand description

A multi-line, wrapped, virtualized-paint text field (D116 Step 4).

Built entirely on the same D116 core TextInput uses — Transaction/ Selection/Command/EditController are unchanged; TextLayoutSnapshot already models “a list of visual lines” so TextArea just populates one LineLayout per WRAPPED line instead of TextInput’s single entry. Click/drag/double/triple-click dispatch in engine.rs is untouched — it only ever talks to editable.layout, never knows which widget it’s looking at.

New in this widget: word-wrapping (wrap_char_ranges below), Enter inserts a real newline (engine.rs, gated on multiline), Up/Down cross wrapped lines with goal-column memory (TextEditState::goal_x), and vertical scrolling via the same zero-wiring rosace_scroll::ScrollController ListView/ScrollView use (D101) — wheel events mutate the controller’s atoms directly, never the render tree, so there’s no !Sync/!Send wall to work around here the way click dispatch has.

Paint is virtualized: every visual line’s geometry is computed each frame (needed for correct click-anywhere/goal-column behavior), but only lines intersecting the current viewport actually emit paint commands — a large document’s PAINT cost stays bounded even though its LAYOUT cost does not yet (a named follow-up, not this step’s exit bar).

Fields§

§value: String§placeholder: String§focused: bool§width: Option<f32>§height: f32§font_size: Option<f32>

None = read from the active theme’s typography.body_medium (D127 “environment” track — see Checkbox::resolved_font_size’s doc for the reasoning).

§radius: f32

Implementations§

Source§

impl TextArea

Source

pub fn new() -> Self

Source

pub fn value(self, v: impl Into<String>) -> Self

Source

pub fn placeholder(self, p: impl Into<String>) -> Self

Source

pub fn focused(self) -> Self

Source

pub fn width(self, w: f32) -> Self

Source

pub fn height(self, h: f32) -> Self

Source

pub fn background(self, c: Color) -> Self

See TextInput::background — same seam, same contract.

Source

pub fn border(self, c: Color) -> Self

See TextInput::border — same seam, same contract.

Source

pub fn focus_color(self, c: Color) -> Self

See TextInput::focus_color — same seam, same contract.

Source

pub fn on_change(self, f: impl Fn(String) + Send + Sync + 'static) -> Self

Source

pub fn controller(self, c: EditController) -> Self

Source

pub fn spans( self, f: impl Fn(&str, Option<(usize, usize)>) -> Vec<Span> + Send + Sync + 'static, ) -> Self

See TextInput::spans — same seam, same contract (D116 Step 5).

Source

pub fn cursor_style(self, s: CursorStyle) -> Self

See TextInput::cursor_style — same seam, same contract.

Source

pub fn field(self, f: FormField) -> Self

See TextInput::field — same seam, same contract (D116 Step 8).

Source

pub fn filters(self, filters: Vec<InputFilter>) -> Self

See TextInput::filters — same seam, same contract.

Source

pub fn no_scrollbar(self) -> Self

Hide the vertical scroll-position thumb (see ScrollView::no_scrollbar — same convention). Content still scrolls; only the indicator is gone.

Source

pub fn scrollbar_color(self, c: Color) -> Self

Trait Implementations§

Source§

impl Default for TextArea

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Widget for TextArea

Source§

fn layout(&self, ctx: &LayoutCtx<'_>) -> Size

Measure under ctx.constraints and return a size within them. Read more
Source§

fn paint(&self, ctx: &mut PaintCtx<'_>)

Record draw commands for ctx.rect. Read more
Source§

fn children(&self) -> Children<'_>

Declare this widget’s children. Drives every default below.
Source§

fn flex_factor(&self) -> f32

Flex weight inside Row/Column. Wrappers are transparent by default.
Source§

fn into_element(self) -> Element
where Self: Sized + 'static,

Wrap this widget in an Element so it can be returned from Component::build().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<W> FocusApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn focus_node(self, node: FocusNode) -> WithFocus<Self>

Attach a focus node. This enables focus-ring rendering and explicit neighbor wiring.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<W> HeroApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn hero_tag(self, tag: impl Into<String>) -> Hero<Self>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> OverlayApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn dropdown( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn sheet( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn dialog( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn rich_tooltip( self, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn toast( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

impl<W> PressApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn on_press(self, f: impl Fn() + Send + Sync + 'static) -> Pressable<Self>

Source§

fn on_long_press( self, f: impl Fn() + Send + Sync + 'static, ) -> LongPressable<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WidgetExt for W
where W: Widget + 'static,

Source§

fn tooltip(self, label: impl Into<String>) -> Tooltip

Show label while the pointer hovers this widget.