Skip to main content

TextSurface

Trait TextSurface 

Source
pub trait TextSurface {
Show 13 methods // Required methods fn can_undo(&self) -> bool; fn can_redo(&self) -> bool; fn undo(&self); fn redo(&self); fn has_selection(&self) -> bool; fn is_read_only(&self) -> bool; fn allows_copy(&self) -> bool; fn cut(&self, ctx: &EventContext<'_>); fn copy(&self, ctx: &EventContext<'_>); fn paste(&self, ctx: &EventContext<'_>); fn paste_plain(&self, ctx: &EventContext<'_>); fn select_all(&self); // Provided method fn history_frozen(&self) -> bool { ... }
}
Expand description

A widget that edits text, seen through the commands a host may need to invoke on it from outside — a menu row, a routed shortcut, an assistive technology.

Object-safe on purpose: a host holds Rc<dyn TextSurface> for whichever widget has focus, without knowing which kind it is.

Required Methods§

Source

fn can_undo(&self) -> bool

Is there anything in this surface’s own history to step back through?

Source

fn can_redo(&self) -> bool

Is there anything to step forward into?

Source

fn undo(&self)

Source

fn redo(&self)

Source

fn has_selection(&self) -> bool

Is any text selected right now?

Source

fn is_read_only(&self) -> bool

Does this surface refuse edits? Cut and Paste are meaningless when it does.

Source

fn allows_copy(&self) -> bool

May its contents be copied at all? A password field says no.

Source

fn cut(&self, ctx: &EventContext<'_>)

Source

fn copy(&self, ctx: &EventContext<'_>)

Source

fn paste(&self, ctx: &EventContext<'_>)

Source

fn paste_plain(&self, ctx: &EventContext<'_>)

Paste stripped of formatting. A surface with no formatting to strip should do a plain paste rather than nothing.

Source

fn select_all(&self)

Provided Methods§

Source

fn history_frozen(&self) -> bool

Is this surface refusing to step through its history at all?

Distinct from having nothing to undo, and a host must treat them differently: an empty history may be a reason to look elsewhere, a refusal is not. Applications impose modes — a “forbid erasing” writing game, a read-only review pass — and a routed Undo that quietly went somewhere else would defeat them.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§