Skip to main content

TextValue

Trait TextValue 

Source
pub trait TextValue: Clone + 'static {
    // Required methods
    fn text(&self) -> String;
    fn shows(&self, text: &str) -> bool;
    fn edit(&self, text: String);

    // Provided method
    fn touch(&self) { ... }
}
Expand description

A value edited as text: text-like and numeric inputs, textarea, a single select, and the value a radio group chooses.

Signal<T> shows T with Display and parses edits with FromStr. Text that does not parse, such as a half-typed number, leaves the signal unchanged.

Required Methods§

Source

fn text(&self) -> String

The text the control shows.

Source

fn shows(&self, text: &str) -> bool

Whether the control’s text already shows this value. Such an edit is never written back, which keeps the cursor and partial input intact.

Source

fn edit(&self, text: String)

Apply the control’s text after a user edit.

Provided Methods§

Source

fn touch(&self)

The control lost focus.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T: FromStr + Display + PartialEq + 'static> TextValue for Signal<T>