pub struct NodeRef { /* private fields */ }Expand description
A handle to the node a view builds, set with .node_ref(…). It follows
the node: a view built again (by Show, For) sets it again, and it’s
None while nothing is built. It also focuses the node from code
(focus, select_text), and
brings a window forward (present).
Implementations§
Source§impl NodeRef
impl NodeRef
pub fn get_untracked(&self) -> Option<NodeId>
Sourcepub fn focus(&self)
pub fn focus(&self)
Gives the control keyboard focus, as a click or Tab would: the
first field of a dialog, say, where the platform wouldn’t focus it
itself. Asked before the control is built (in a window’s
on_open), it’s focused once it is.
Sourcepub fn select_text(&self, range: Range<usize>)
pub fn select_text(&self, range: Range<usize>)
Focuses a text field or text area and selects these characters of
its text, counted as people see them: grapheme clusters, so an
accented letter or an emoji made of several code points is one
(text.graphemes(true), from the re-exported unicode_segmentation).
A file’s name without its extension, say, as file managers select
one to rename. Cut to the text’s end; other controls are only
focused. Asked before the field is built, it’s done once it is,
after its first text.
Sourcepub fn present(&self)
pub fn present(&self)
Brings the window forward (the one this node is in, or the window
itself, given Window::node_ref), as the platform’s apps do when asked to
show a window that’s open already: from a tray menu’s Open item, or
a later launch. The app comes forward with it, a minimized window
is restored, and it takes the keys. Asked while the window is
closed, it’s done once it opens: open.set(true) with this shows
it whether it was closed or behind other apps’ windows.
Platforms may refuse to take the focus from another app: on Wayland the compositor only gives it for a user’s action it can tell (a launch’s token), and asks for attention otherwise.