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§
Sourcefn can_undo(&self) -> bool
fn can_undo(&self) -> bool
Is there anything in this surface’s own history to step back through?
fn undo(&self)
fn redo(&self)
Sourcefn has_selection(&self) -> bool
fn has_selection(&self) -> bool
Is any text selected right now?
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Does this surface refuse edits? Cut and Paste are meaningless when it does.
Sourcefn allows_copy(&self) -> bool
fn allows_copy(&self) -> bool
May its contents be copied at all? A password field says no.
fn cut(&self, ctx: &EventContext<'_>)
fn copy(&self, ctx: &EventContext<'_>)
fn paste(&self, ctx: &EventContext<'_>)
Sourcefn paste_plain(&self, ctx: &EventContext<'_>)
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.
fn select_all(&self)
Provided Methods§
Sourcefn history_frozen(&self) -> bool
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".