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.
Sourcepub fn letter_spacing(self, sp: f32) -> Self
pub fn letter_spacing(self, sp: f32) -> Self
Explicit letter spacing in sp.
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.
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 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.