Skip to main content

LineEditor

Trait LineEditor 

Source
pub trait LineEditor:
    'static
    + Sized
    + EntityInputHandler {
    // Required methods
    fn edit(&self) -> &TextEdit;
    fn edit_mut(&mut self) -> &mut TextEdit;
    fn line(&self) -> &LineState;
    fn line_mut(&mut self) -> &mut LineState;
    fn line_focus(&self) -> &FocusHandle;
    fn line_changed(&mut self, cx: &mut Context<'_, Self>);

    // Provided methods
    fn line_masked(&self) -> bool { ... }
    fn line_read_only(&self) -> bool { ... }
    fn line_max_length(&self) -> Option<usize> { ... }
    fn line_filter(&self, text: String) -> String { ... }
}
Expand description

A field that can be drawn and driven by this module’s Line element.

Implementors keep the buffer and the LineState; everything else — glyph layout, hit-testing, scrolling, IME, the clipboard — is shared. The platform trait comes along for the ride: a field that can be drawn by Line is by definition one the OS can drive text into, and every implementor gets it from the crate’s line_input_handler! macro.

Required Methods§

Source

fn edit(&self) -> &TextEdit

Source

fn edit_mut(&mut self) -> &mut TextEdit

Source

fn line(&self) -> &LineState

Source

fn line_mut(&mut self) -> &mut LineState

Source

fn line_focus(&self) -> &FocusHandle

Source

fn line_changed(&mut self, cx: &mut Context<'_, Self>)

Called after any mutation so the field can emit its change event. The element never calls cx.notify on the host’s behalf; do it here.

Provided Methods§

Source

fn line_masked(&self) -> bool

Show bullets instead of characters, and refuse to copy or cut.

Source

fn line_read_only(&self) -> bool

Accept focus, selection, and copy, but reject every mutation.

Source

fn line_max_length(&self) -> Option<usize>

Cap on the value’s length in chars, enforced on typing and on paste the way an <input maxlength> is.

Source

fn line_filter(&self, text: String) -> String

Narrow what may be entered, the way <input type="number"> does. Returns the text to actually insert; dropping every char rejects the input. Applied to typing, IME, drops, and paste alike, so a field can’t be filled with something it rejects by any route.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§