pub struct TextArea<Msg> { /* private fields */ }Expand description
A multi-line text field with word wrap, scrolling and real editing.
Long lines wrap at word boundaries and the area scrolls vertically with a scrollbar once the
text is taller than the area. The area measures three to eight rows, growing with its
content; give the node a height for a fixed size. The application owns the value and
receives every change through on_change; cursor, selection, scroll and undo history live
in the runtime.
Keys: Enter inserts a line break. ←/→ move (with Ctrl by word), ↑/↓ move between rows
keeping the column, Page Up/Page Down move a page, Home/End go to the row’s start and end
(with Ctrl to the text’s), and Shift extends the selection with any of them. Without Shift an
arrow clears a selection and moves one step on from its end in that direction. Backspace and
Delete, Ctrl+W deletes a word, Ctrl+U deletes to the line start, Ctrl+A selects all,
Ctrl+Z undo, Ctrl+Y or Ctrl+Shift+Z redo, Ctrl+C and Ctrl+X copy and cut. Ctrl+Enter
submits when TextArea::on_submit is set; terminals without the kitty keyboard protocol
may not report it, so offer a button as well. Pasting keeps line breaks. Clicking places the
cursor, dragging selects, the wheel and the scrollbar scroll.
A right click (or Shift+F10 and the menu key) opens the edit menu of
TextInput: Cut, Copy, Paste and Select all, with the same rules.
Style keys: text-area (bg, fg, padding) with hover, focus, invalid,
disabled; text-area-line-number (fg) with selected on the cursor’s line;
text-area-counter (fg); and the text input’s text-input-placeholder,
text-input-selection, text-input-cursor and scrollbar.
Implementations§
Source§impl<Msg: 'static> TextArea<Msg>
impl<Msg: 'static> TextArea<Msg>
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
Faint text shown while the area is empty.
Sourcepub fn max_length(self, max: usize) -> Self
pub fn max_length(self, max: usize) -> Self
Limits the value to max characters; a line break counts as one.
Sourcepub fn line_numbers(self, on: bool) -> Self
pub fn line_numbers(self, on: bool) -> Self
Numbers every line in a faint column on the left; wrapped rows are not numbered.
Sourcepub fn counter(self, on: bool) -> Self
pub fn counter(self, on: bool) -> Self
Shows the character count on a row below the text, with the limit when there is one.
Trait Implementations§
Source§impl<Msg: 'static> Widget<Msg> for TextArea<Msg>
impl<Msg: 'static> Widget<Msg> for TextArea<Msg>
Source§fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
fn paint_overlay(&self, cx: &mut PaintCx<'_>, anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for TextArea<Msg>
impl<Msg> !Send for TextArea<Msg>
impl<Msg> !Sync for TextArea<Msg>
impl<Msg> !UnwindSafe for TextArea<Msg>
impl<Msg> Freeze for TextArea<Msg>
impl<Msg> Unpin for TextArea<Msg>
impl<Msg> UnsafeUnpin for TextArea<Msg>
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> 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