pub struct TextSurfaces { /* private fields */ }Expand description
A cloneable view of one tree’s registered text surfaces.
Taken once, with BuildContext::text_surfaces, and held by whatever needs
to ask the question later — a view-model refreshed from a frame tick has no
&WidgetTree to consult, which is precisely when it needs the answer.
Implementations§
Source§impl TextSurfaces
impl TextSurfaces
Sourcepub fn focused(&self) -> Option<Rc<dyn TextSurface>>
pub fn focused(&self) -> Option<Rc<dyn TextSurface>>
The text-editing widget that currently holds the keyboard focus.
None when focus is elsewhere — or nowhere — which is exactly what a
host needs in order to know that a text chord is safe to route itself.
Sourcepub fn focused_is_text_surface(&self) -> bool
pub fn focused_is_text_surface(&self) -> bool
Is the keyboard focus inside a widget that edits text? The cheap half of
focused, for a host that only needs to decide whether
to step aside.
Sourcepub fn is_read_only(&self, owner: WidgetId) -> bool
pub fn is_read_only(&self, owner: WidgetId) -> bool
Does the widget registered under owner refuse edits?
false for a widget that edits nothing — the question is only asked of
text surfaces, and a node that is not one is not read-only, it is simply
not text. Read by the hit-test slop pass, which must never re-attribute
a press to a surface that would ignore it.
Sourcepub fn set_empty_history_passes_on(&self, on: bool)
pub fn set_empty_history_passes_on(&self, on: bool)
Make every text widget of this tree decline Undo when it has nothing to undo, and Redo when it has nothing to redo, so the intent goes on to an ancestor’s action — the application’s own history — instead of stopping at a widget that would do nothing with it. See the module documentation.
Off by default. Applies to RichTextEditor, TextInputField and the
fields built on it, and CodeEditor, from the next command they
receive; set it once, from the root’s build. The widgets ask their
document at the moment the command runs, never a cached
can_undo, so a keystroke typed a moment
earlier is always undone where it was typed.
Sourcepub fn empty_history_passes_on(&self) -> bool
pub fn empty_history_passes_on(&self) -> bool
Whether a text widget with nothing to undo (or redo) passes the command
on. See set_empty_history_passes_on.
Sourcepub fn focus_signal(&self) -> Signal<Option<WidgetId>>
pub fn focus_signal(&self) -> Signal<Option<WidgetId>>
The signal to react to. A host mirroring “can undo” into a menu row re-reads when focus moves.