TextInput

TextInput小部件是一个可自定义的文本输入字段,具有各种样式和行为选项。它支持动画、光标样式、文本选择和撤消/重做功能等功能。

The TextInput widget is a customizable text input field with various styling and behavior options. It supports features like animation, cursor styling, text selection, and undo/redo functionality.

Props

decoratenametypedescription
animatoranimatorAnimatorAnimator for handling animation states.
redraw, livedraw_bgDrawColorBackground color drawing properties.
livedraw_selectDrawQuadDrawing properties for text selection.
livedraw_cursorDrawQuadDrawing properties for the cursor.
livedraw_textDrawLabelDrawing properties for the text.
walkwalkWalkLayout and positioning properties.
layoutlayoutLayoutLayout properties for arranging child elements.
livelabel_alignAlignAlignment properties for the label.
livecursor_sizef64Size of the cursor.
livecursor_margin_bottomf64Bottom margin for the cursor.
livecursor_margin_topf64Top margin for the cursor.
liveselect_pad_edgesf64Padding edges for text selection.
liveempty_messageStringMessage displayed when the input is empty.
livenumeric_onlyboolRestricts input to numeric values only.
livesecretboolHides the text input for password fields.
liveon_focus_select_allboolSelects all text when the input gains focus.
liveread_onlyboolMakes the text input read-only.
livetextStringThe text content of the input field.
liveascii_onlyboolRestricts input to ASCII characters only.
rustdouble_tap_startOption<(usize, usize)>Stores the start position for double-tap selection.
rustundo_idu64Identifier for the undo action.
rustlast_undoOption<UndoItem>The last undo item.
rustundo_stackVec<UndoItem>Stack of undo items.
rustredo_stackVec<UndoItem>Stack of redo items.
rustcursor_tailusizeTail position of the cursor.
rustcursor_headusizeHead position of the cursor.

Event

namedescription
Change(String)Triggered when the text content changes.
Return(String)Triggered when the return key is pressed.
EscapeTriggered when the escape key is pressed.
KeyFocusTriggered when the input gains keyboard focus.
KeyFocusLostTriggered when the input loses keyboard focus.
NoneRepresents no action.