pub struct Textarea {
pub style: Style,
pub text_color: Color,
/* private fields */
}Expand description
Multi-line editable text area widget (LPAR-14 §5.C).
Wraps EditCore (promoted to rlvgl_core) for the mutation model and
uses the LPAR-08 greedy-wrap algorithm for line layout. Supports
placeholder text, password masking, optional single-line mode, and vertical
overflow scrolling.
§Key navigation
Wire a Keyboard hook to
apply_key_output:
keyboard.set_key_output_hook(|ko| ta.apply_key_output(ko));For direct key injection (hardware keyboard / test harness) use
Widget::handle_event with Event::KeyDown.
Fields§
§style: StyleWidget style (background, border).
text_color: ColorText colour.
Implementations§
Source§impl Textarea
impl Textarea
Sourcepub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
Replace the buffer with text programmatically.
Bypasses the ASCII gate and accept predicate. Clamps the caret to
the new length. Fires on_change if registered.
Sourcepub fn set_placeholder(&mut self, text: &str)
pub fn set_placeholder(&mut self, text: &str)
Set the placeholder string shown when the buffer is empty and the
field is inactive. Pass "" to clear.
Sourcepub fn placeholder(&self) -> Option<&str>
pub fn placeholder(&self) -> Option<&str>
Return the current placeholder string, if any.
Sourcepub fn set_password_mode(&mut self, enable: bool)
pub fn set_password_mode(&mut self, enable: bool)
Enable or disable password masking.
When enabled, every character in the rendered display is replaced by
[PASSWORD_GLYPH] (*). The buffer stores the real text.
Sourcepub fn password_mode(&self) -> bool
pub fn password_mode(&self) -> bool
Return true if password masking is active.
Sourcepub fn set_one_line(&mut self, enable: bool)
pub fn set_one_line(&mut self, enable: bool)
Enable or disable single-line mode.
In one-line mode:
'\n'is never inserted; Enter fireson_submitinstead.- Wrapping is suppressed; the content scrolls horizontally.
Sourcepub fn set_active(&mut self, active: bool)
pub fn set_active(&mut self, active: bool)
Toggle key consumption. Applications keep at most one field active; no focus framework is imposed (WID-00 §7.1).
Sourcepub fn widget_style(&self) -> &Style
pub fn widget_style(&self) -> &Style
Immutable access to the widget style.
Sourcepub fn widget_style_mut(&mut self) -> &mut Style
pub fn widget_style_mut(&mut self) -> &mut Style
Mutable access to the widget style.
Sourcepub fn set_font(&mut self, font: &'static dyn FontMetrics)
pub fn set_font(&mut self, font: &'static dyn FontMetrics)
Assign the font used to render this widget (FONT-00 §5); resolves to
FONT_6X10 when unset.
Sourcepub fn on_change<F: FnMut(&str) + 'static>(self, handler: F) -> Self
pub fn on_change<F: FnMut(&str) + 'static>(self, handler: F) -> Self
Register a change callback invoked after every committed edit and on
programmatic set_text calls.
Sourcepub fn on_submit<F: FnMut(&str) + 'static>(self, handler: F) -> Self
pub fn on_submit<F: FnMut(&str) + 'static>(self, handler: F) -> Self
Register a submit callback fired when Enter is pressed in one-line mode.
Sourcepub fn with_accept<F: Fn(char) -> bool + 'static>(self, accept: F) -> Self
pub fn with_accept<F: Fn(char) -> bool + 'static>(self, accept: F) -> Self
Install an accepted-charset predicate (evaluated after the ASCII gate).
Sourcepub fn with_max_len(self, max: usize) -> Self
pub fn with_max_len(self, max: usize) -> Self
Cap the buffer at max characters.
Sourcepub fn apply_key_output(&mut self, ko: KeyOutput)
pub fn apply_key_output(&mut self, ko: KeyOutput)
Apply a KeyOutput value produced by a [Keyboard] widget.
Mapping (LPAR-14 §5.I):
KeyOutput | one-line=false | one-line=true |
|---|---|---|
Char(c) | try_insert(c) | try_insert(c) |
Backspace | try_backspace() | try_backspace() |
Enter | try_insert('\n') | fire on_submit, no mutation |
Tab | ignored | ignored |
Escape | deactivate | deactivate |
Control(_) | ignored (mode handled by Keyboard) | same |
Sourcepub fn scroll_offset_y(&self) -> i32
pub fn scroll_offset_y(&self) -> i32
Return the current vertical scroll offset in pixels.