pub struct TextFieldScope { /* private fields */ }Expand description
A TextField and its builder.
Implementations§
Source§impl TextFieldScope
impl TextFieldScope
Sourcepub fn text(self, text: impl Into<String>) -> Self
pub fn text(self, text: impl Into<String>) -> Self
The text the field starts with. Only the start: the field stays uncontrolled, so
what the user types is never written back, and a later value here changes nothing
on the field that is already there. To show other text, such as another document,
give the field a new identity with key, and the new field starts with this text.
pub fn placeholder(self, placeholder: impl Into<String>) -> Self
pub fn enabled(self, enabled: bool) -> Self
pub fn multiline(self, multiline: bool) -> Self
Sourcepub fn type_role(self, role: TypeRole) -> Self
pub fn type_role(self, role: TypeRole) -> Self
The rung of the type ladder the field’s own text is set in.
Sourcepub fn font_size(self, sp: f32) -> Self
pub fn font_size(self, sp: f32) -> Self
Explicit font size in sp. Overrides the type role’s size.
Sourcepub fn font_weight(self, weight: u16) -> Self
pub fn font_weight(self, weight: u16) -> Self
Explicit font weight (e.g. 400, 500, 600, 700). Overrides the type role’s weight.
Sourcepub fn line_height(self, sp: f32) -> Self
pub fn line_height(self, sp: f32) -> Self
Explicit line height in sp, or NaN (normal) to use the font’s own metrics. An unset line height (0 or never calling this) falls back to the type role’s line height.
Sourcepub fn letter_spacing(self, sp: f32) -> Self
pub fn letter_spacing(self, sp: f32) -> Self
Explicit letter spacing in sp.
Sourcepub fn placeholder_color(self, paint: Paint) -> Self
pub fn placeholder_color(self, paint: Paint) -> Self
Explicit placeholder text colour. Sent only when set; absent keeps the design system’s default.
Sourcepub fn caret_color(self, paint: Paint) -> Self
pub fn caret_color(self, paint: Paint) -> Self
Explicit caret colour. Sent only when set; absent keeps the design system’s default.
Sourcepub fn font(self, font: FontRefs) -> Self
pub fn font(self, font: FontRefs) -> Self
The fonts to try for the field’s text, in order. Taken only with TypeRole::None.
Sourcepub fn font_feature_settings(self, features: &[FontFeature]) -> Self
pub fn font_feature_settings(self, features: &[FontFeature]) -> Self
OpenType features for the typed text and the placeholder, as
Text::font_feature_settings takes them. Taken with or without a type role.
Sourcepub fn word_break(self, word_break: WordBreak) -> Self
pub fn word_break(self, word_break: WordBreak) -> Self
Where a line of the typed text and of the placeholder may break inside a word, as
Text::word_break does. CSS word-break.
Sourcepub fn overflow_wrap(self, overflow_wrap: OverflowWrap) -> Self
pub fn overflow_wrap(self, overflow_wrap: OverflowWrap) -> Self
Whether a token too long for its line may break inside itself, in the typed text
and the placeholder, as Text::overflow_wrap does. CSS overflow-wrap.
pub fn on_value_change(self, handler: impl FnMut(String) + 'static) -> Self
pub fn on_submit(self, handler: impl FnMut(String) + 'static) -> Self
pub fn on_focus_gained(self, handler: impl FnMut() + 'static) -> Self
pub fn on_focus_lost(self, handler: impl FnMut() + 'static) -> Self
Sourcepub fn on_key_down(self, handler: impl FnMut(KeyEvent) + 'static) -> Self
pub fn on_key_down(self, handler: impl FnMut(KeyEvent) + 'static) -> Self
Sees each key the field is pressed with; calling consume on the event keeps the
field from acting on it.
Sourcepub fn on_key_up(self, handler: impl FnMut(KeyEvent) + 'static) -> Self
pub fn on_key_up(self, handler: impl FnMut(KeyEvent) + 'static) -> Self
Sees each key released while the field holds focus.
Sourcepub fn on_composition_change(self, handler: impl FnMut(bool) + 'static) -> Self
pub fn on_composition_change(self, handler: impl FnMut(bool) + 'static) -> Self
Reports when an input method begins or ends an active composition in the field.
Sourcepub fn focus_handle(self, handle: &FocusHandle) -> Self
pub fn focus_handle(self, handle: &FocusHandle) -> Self
Binds handle to this field, so handle.request() puts keyboard focus here.
Sourcepub fn on_motion_finished(
self,
handler: impl FnMut(MotionFinished) + 'static,
) -> Self
pub fn on_motion_finished( self, handler: impl FnMut(MotionFinished) + 'static, ) -> Self
Runs once when the field’s size motion comes to rest, with the size it settled at
in dp. The field needs Modifier::motion for its size to move; without it nothing
is reported. A run interrupted by a newer size is not reported, only the one that
settles.
Sourcepub fn bare(self) -> Self
pub fn bare(self) -> Self
Draws the field without the design system’s frame: no fill, line, underline,
corner clip, inner padding, minimum height or focus line. Text, placeholder, caret,
selection and input methods stay as they are. For a field that sits inside a box
which already draws its own frame, so the frame is not drawn twice. A background
or border given on the node is still drawn.