Skip to content

TextInput ​

Путь подключения: require "ProjectMotionUI/Components/TextInput"


Класс PMUI.TextInput ​

Наследуется от: PMUI.BaseElement

Методы и функции ​

PMUI.TextInput:new(placeholder) ​

Creates a text input field with an optional placeholder.

ПараметрТипОписание
placeholderstring|nilText displayed when the input is empty and unfocused.

Returns: PMUI.TextInput

PMUI.TextInput:instantiate() ​

Initializes the base element and its native text entry control. Adds the input control as a child and synchronizes its dimensions.

PMUI.TextInput:SyncEntrySize() ​

Synchronizes the native text entry dimensions with the parent element. Updates both the Lua control and its Java UI object when available.

PMUI.TextInput:RecalculateLayout() ​

Recalculates the element layout and updates the native input dimensions.

PMUI.TextInput:GetText() ​

Returns the current text entered by the user.

Returns: string

PMUI.TextInput:SetText(text) ​

Sets the text displayed in the input field.

ПараметрТипОписание
textstring|nilText to assign. Nil is treated as an empty string.

Returns: PMUI.TextInput

PMUI.TextInput:OnChange(callback) ​

Registers a callback invoked whenever the input text changes. The callback receives the current text and the TextInput instance.

ПараметрТипОписание
callbackfunction|nilText change callback.

Returns: PMUI.TextInput

PMUI.TextInput:render() ​

Renders the native input control and its placeholder when applicable. The placeholder is hidden while the field is focused or contains text.

PMUI.TextInput:SaveState(data) ​

Saves the current input text into the provided state table.

ПараметрТипОписание
datatableState table to populate.

PMUI.TextInput:LoadState(data) ​

Restores the input text from a previously saved state.

ПараметрТипОписание
datatableState table containing the saved text.