Skip to main content

Editor

Struct Editor 

Source
pub struct Editor { /* private fields */ }
Expand description

Editor component

Implementations§

Source§

impl Editor

API for use by EditGuard implementations

Source

pub fn id_ref(&self) -> &Id

Get a reference to the widget’s identifier

Source

pub fn id(&self) -> Id

Get the widget’s identifier

Source

pub fn as_str(&self) -> &str

Get text contents

Source

pub fn clone_string(&self) -> String

Get the text contents as a String

Source

pub fn pre_commit(&mut self)

Commit outstanding changes to the undo history

Call this before changing the text with set_str or set_string to commit changes to the undo history.

Source

pub fn clear(&mut self, cx: &mut EventState)

Clear text contents and undo history

This method does not call any EditGuard actions; consider also calling EditField::call_guard_edit.

Source

pub fn set_str(&mut self, cx: &mut EventState, text: &str) -> bool

Set text contents from a str

This does not interact with undo history; see also Self::clear, Self::pre_commit.

This method does not call any EditGuard actions; consider also calling EditField::call_guard_edit.

Returns true if the text may have changed.

Source

pub fn set_string(&mut self, cx: &mut EventState, string: String) -> bool

Set text contents from a String

This does not interact with undo history or call action handlers on the guard.

This method clears the error state but does not call any EditGuard actions; consider also calling EditField::call_guard_edit.

Returns true if the text is ready and may have changed.

Source

pub fn replace_selected_text(&mut self, cx: &mut EventState, text: &str) -> bool

Replace selected text

This does not interact with undo history or call action handlers on the guard.

This method clears the error state but does not call any EditGuard actions; consider also calling EditField::call_guard_edit.

Returns true if the text is ready and may have changed.

Source

pub fn cursor_range(&self) -> CursorRange

Access the cursor index / selection range

Source

pub fn set_cursor_range(&mut self, range: impl Into<CursorRange>)

Set the cursor index / range

This does not interact with undo history or call action handlers on the guard.

Source

pub fn is_editable(&self) -> bool

Get whether this EditField is editable

Source

pub fn set_editable(&mut self, editable: bool)

Set whether this EditField is editable

Source

pub fn multi_line(&self) -> bool

True if the editor uses multi-line mode

Source

pub fn class(&self) -> TextClass

Get the text class used

Source

pub fn has_input_focus(&self) -> bool

Get whether the widget has input focus

This is true when the widget is has keyboard or IME focus.

Source

pub fn has_error(&self) -> bool

Get whether the input state is erroneous

Source

pub fn set_error( &mut self, cx: &mut EventState, message: Option<Cow<'static, str>>, )

Mark the input as erroneous with an optional message

This state should be set from EditGuard::edit when appropriate. The state is cleared immediately before calling EditGuard::edit and also in case a text is directly assigned (e.g. using Self::set_string).

When set, the input field’s background is drawn red. If a message is supplied, then a tooltip will be available on mouse-hover.

Trait Implementations§

Source§

impl Debug for Editor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Editor

§

impl RefUnwindSafe for Editor

§

impl !Send for Editor

§

impl !Sync for Editor

§

impl Unpin for Editor

§

impl UnwindSafe for Editor

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<S, T> Cast<T> for S
where T: Conv<S>,

Source§

fn cast(self) -> T

Cast from Self to T Read more
Source§

fn try_cast(self) -> Result<T, Error>

Try converting from Self to T Read more
Source§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

Source§

fn try_cast_approx(self) -> Result<T, Error>

Try approximate conversion from Self to T Read more
Source§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
Source§

impl<S, T> CastFloat<T> for S
where T: ConvFloat<S>,

Source§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
Source§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
Source§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
Source§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
Source§

fn try_cast_trunc(self) -> Result<T, Error>

Try converting to integer with truncation Read more
Source§

fn try_cast_nearest(self) -> Result<T, Error>

Try converting to the nearest integer Read more
Source§

fn try_cast_floor(self) -> Result<T, Error>

Try converting the floor to an integer Read more
Source§

fn try_cast_ceil(self) -> Result<T, Error>

Try convert the ceiling to an integer Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,