Skip to main content

TextSurfaces

Struct TextSurfaces 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for TextSurfaces

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextSurfaces

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.