[][src]Struct druid::text::Editor

pub struct Editor<T> { /* fields omitted */ }

A component for widgets that offer text editing.

Editor manages an EditableText type, applying edits and maintaining selection state.

The type parameter T is the text data being edited.

Implementations

impl<T> Editor<T>[src]

pub fn new() -> Self[src]

Create a new Editor.

pub fn set_multiline(&mut self, multiline: bool)[src]

Set whether the editor supports multi-line text. Default to false.

If this is false, inserted text will only insert up to the first included newline.

pub fn set_wrap_width(&mut self, width: f64)[src]

Set an explicit wrap width for this editor.

By default the editor will not wrap lines; this is suitable for cases such as a a single-line text field, where the containing widget will scroll the editor as required.

pub fn layout(&self) -> &TextLayout<T>[src]

Return a reference to the inner TextLayout object.

pub fn layout_mut(&mut self) -> &mut TextLayout<T>[src]

Return a mutable reference to the inner TextLayout object.

impl<T: TextStorage + EditableText> Editor<T>[src]

pub fn set_text(&mut self, text: T)[src]

Set the text for this editor.

This must be set before the editor is used, such as in WidgetAdded.

pub fn selection(&self) -> &Selection[src]

Return the current selection.

pub fn set_selection(&mut self, selection: Selection)[src]

Set the current selection.

The selection will be constrained to the current text.

pub fn selection_rects(&self) -> Vec<Rect>[src]

Returns the Rects representing the current selection.

pub fn cursor_line(&self) -> Line[src]

Returns the Line to draw for the current cursor position.

pub fn click(&mut self, mouse: &MouseEvent, data: &mut T)[src]

Handle a mouse click

pub fn drag(&mut self, mouse: &MouseEvent, data: &mut T)[src]

Handle a mouse drag

pub fn copy(&self, data: &mut T)[src]

Handle a copy command

pub fn cut(&mut self, data: &mut T)[src]

Handle a cut command

pub fn paste(&mut self, t: String, data: &mut T)[src]

Handle a paste command

pub fn select_all(&mut self, data: &T)[src]

Set the selection to the entire buffer.

pub fn update(&mut self, ctx: &mut UpdateCtx<'_, '_>, new_data: &T, env: &Env)[src]

Update the editor if the data or env has changed.

The widget owning this Editor must call this method during its own update call.

pub fn rebuild_if_needed(&mut self, factory: &mut PietText, env: &Env)[src]

Must be called in WidgetAdded

pub fn do_edit(&mut self, edit: EditAction, data: &mut T)[src]

Perform an EditAction.

pub fn draw(&self, ctx: &mut PaintCtx<'_, '_, '_>, point: impl Into<Point>)[src]

Draw this editor at the provided point.

Trait Implementations

impl<T: Clone> Clone for Editor<T>[src]

impl<T: Debug> Debug for Editor<T>[src]

impl<T> Default for Editor<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Editor<T>[src]

impl<T> !Send for Editor<T>[src]

impl<T> !Sync for Editor<T>[src]

impl<T> Unpin for Editor<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Editor<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.