Skip to main content

TextFieldModifierNode

Struct TextFieldModifierNode 

Source
pub struct TextFieldModifierNode { /* private fields */ }
Expand description

The modifier node behind an editable text field. It measures and draws the text, the cursor and the selection, and handles pointer input.

Implementations§

Source§

impl TextFieldModifierNode

Source

pub fn new(state: TextFieldState, style: TextStyle) -> Self

Creates a new text field modifier node.

Source

pub fn with_line_limits(self, line_limits: TextFieldLineLimits) -> Self

Creates a node with custom line limits.

Source

pub fn with_handle_controller( self, controller: TextFieldHandleController, ) -> Self

Installs the controller the field publishes live handle metrics to.

Source

pub fn text_pan_resolver(&self) -> Option<TextPanResolver>

Returns the pan resolver for single-line fields, None for multi-line.

Exposed to the modifier slices so the render scene builder can pan the text glyphs by the same offset used for the cursor and selection.

Source

pub fn scroll_offset(&self) -> f32

Returns the current horizontal scroll (pan) offset in px.

Source

pub fn line_limits(&self) -> TextFieldLineLimits

Returns the current line limits configuration.

Source

pub fn with_cursor_color(self, color: Color) -> Self

Creates a node with a custom accent: the caret is drawn solid in color and the selection highlight is derived from it at crate::widgets::SELECTION_HIGHLIGHT_ALPHA — the reference field tints caret, handles and highlight from the one accent.

Source

pub fn set_focused(&mut self, focused: bool)

Sets the focus state.

Source

pub fn is_focused(&self) -> bool

Returns whether the field is focused.

Source

pub fn text(&self) -> String

Returns the current text.

Source

pub fn style(&self) -> &TextStyle

Returns the text style the field lays out and draws with.

Source

pub fn selection(&self) -> TextRange

Returns the current selection.

Source

pub fn cursor_brush(&self) -> Brush

Returns the cursor brush for rendering.

Source

pub fn selection_brush(&self) -> Brush

Returns the selection brush for rendering selection highlight.

Trait Implementations§

Source§

impl Debug for TextFieldModifierNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl DelegatableNode for TextFieldModifierNode

Source§

fn node_state(&self) -> &NodeState

The runtime state of this node. Return a NodeState field of the node; the chain uses it to link the node and to track its capabilities.
Source§

fn aggregate_child_capabilities(&self) -> NodeCapabilities

The union of the capabilities of this node and of every node after it in the chain.
Source§

impl DrawModifierNode for TextFieldModifierNode

Source§

fn create_draw_closure(&self) -> Option<Rc<dyn Fn(&mut DrawScopeDefault)>>

Creates a closure for deferred drawing that will be evaluated at render time. Read more
Source§

fn create_behind_draw_closure( &self, ) -> Option<Rc<dyn Fn(&mut DrawScopeDefault)>>

Like create_draw_closure, but the primitives render BEHIND the node’s content — e.g. a text field’s selection highlight, which must sit under the glyphs (a highlight drawn over them tints the text with its translucent fill).
Source§

impl LayoutModifierNode for TextFieldModifierNode

Source§

fn measure( &self, context: &mut dyn ModifierNodeContext, _measurable: &dyn Measurable, constraints: Constraints, ) -> LayoutModifierMeasureResult

Measures the wrapped content and returns both the size this modifier occupies and where the wrapped content should be placed. Read more
Source§

fn min_intrinsic_width( &self, _measurable: &dyn Measurable, _height: f32, density: f32, ) -> f32

Returns the minimum intrinsic width of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Source§

fn max_intrinsic_width( &self, _measurable: &dyn Measurable, _height: f32, density: f32, ) -> f32

Returns the maximum intrinsic width of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Source§

fn min_intrinsic_height( &self, _measurable: &dyn Measurable, width: f32, density: f32, ) -> f32

Returns the minimum intrinsic height of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Source§

fn max_intrinsic_height( &self, _measurable: &dyn Measurable, width: f32, density: f32, ) -> f32

Returns the maximum intrinsic height of this modifier node. The default is the wrapped content’s, for a node that keeps the content’s size.
Source§

fn measure_hold( &self, _density: f32, _constraints: Constraints, _size: Size, _wrapped: WrappedHold, ) -> Option<ConstraintsHold>

The incoming constraints the last measure of this node, which gave size under constraints, holds for: every constraints inside give the same result. wrapped is what the content this node wraps measured. None, the default, holds for constraints alone; a node that tells must give the range its own measure keeps its result and hands its content constraints that wrapped holds for.
Source§

impl ModifierNode for TextFieldModifierNode

Source§

fn on_attach(&mut self, context: &mut dyn ModifierNodeContext)

Called once when the node joins an attached chain. context receives the invalidation requests of the node.
Source§

fn on_detach(&mut self)

Called when the node leaves the chain or when the chain detaches. Release here whatever on_attach acquired.
Source§

fn as_draw_node(&self) -> Option<&dyn DrawModifierNode>

Returns this node as a draw modifier if it implements the trait.
Source§

fn as_draw_node_mut(&mut self) -> Option<&mut dyn DrawModifierNode>

Returns this node as a mutable draw modifier if it implements the trait.
Source§

fn as_layout_node(&self) -> Option<&dyn LayoutModifierNode>

Returns this node as a layout modifier if it implements the trait.
Source§

fn as_layout_node_mut(&mut self) -> Option<&mut dyn LayoutModifierNode>

Returns this node as a mutable layout modifier if it implements the trait.
Source§

fn as_semantics_node(&self) -> Option<&dyn SemanticsNode>

Returns this node as a semantics modifier if it implements the trait.
Source§

fn as_semantics_node_mut(&mut self) -> Option<&mut dyn SemanticsNode>

Returns this node as a mutable semantics modifier if it implements the trait.
Source§

fn as_pointer_input_node(&self) -> Option<&dyn PointerInputNode>

Returns this node as a pointer-input modifier if it implements the trait.
Source§

fn as_pointer_input_node_mut(&mut self) -> Option<&mut dyn PointerInputNode>

Returns this node as a mutable pointer-input modifier if it implements the trait.
Source§

fn on_reset(&mut self)

Called when the chain is reset, as Compose’s onReset. Clear state that belongs to an earlier use of the node.
Source§

fn as_focus_node(&self) -> Option<&(dyn FocusNode + 'static)>

Returns this node as a focus modifier if it implements the trait.
Source§

fn as_focus_node_mut(&mut self) -> Option<&mut (dyn FocusNode + 'static)>

Returns this node as a mutable focus modifier if it implements the trait.
Source§

fn for_each_delegate<'b>( &'b self, _visitor: &mut dyn FnMut(&'b (dyn ModifierNode + 'static)), )

Visits every delegate node owned by this modifier.
Source§

fn for_each_delegate_mut<'b>( &'b mut self, _visitor: &mut dyn FnMut(&'b mut (dyn ModifierNode + 'static)), )

Visits every delegate node mutably.
Source§

impl PointerInputNode for TextFieldModifierNode

Source§

fn on_pointer_event( &mut self, _context: &mut dyn ModifierNodeContext, _event: &PointerEvent, ) -> bool

Called when a pointer event occurs within the bounds of this node. Returns true if the event was consumed and should not propagate further.
Source§

fn hit_test(&self, x: f32, y: f32) -> bool

Returns true if this node should participate in hit-testing for the given pointer position.
Source§

fn pointer_input_handler(&self) -> Option<Rc<dyn Fn(PointerEvent)>>

Returns an event handler closure if the node wants to participate in pointer dispatch.
Source§

fn layout_size_sink(&self) -> Option<Rc<Cell<Size>>>

Returns the cell this node reads its owning layout node’s resolved size from, if it exposes a size to its handler (Compose’s PointerInputScope.size). Read more
Source§

impl SemanticsNode for TextFieldModifierNode

Source§

fn reach(&self) -> SemanticsReach

Neither modal nor hidden, but the field’s text and selection are read live from its state, which an app may set without touching the node.

Source§

fn merge_semantics(&self, config: &mut SemanticsConfiguration)

Merges semantic properties into the provided configuration.

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> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.