[−][src]Struct druid::text::Editor
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 Rect
s 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]
T: Unpin,
impl<T> !UnwindSafe for Editor<T>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,