Skip to content

TextInput ​

Require path: require "ProjectMotionUI/Components/TextInput"


Class PMUI.TextInput ​

Inherits from: PMUI.BaseElement

Methods & Functions ​

PMUI.TextInput:new(placeholder) ​

Creates a text input field with an optional placeholder.

ParameterTypeDescription
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.

ParameterTypeDescription
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.

ParameterTypeDescription
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.

ParameterTypeDescription
datatableState table to populate.

PMUI.TextInput:LoadState(data) ​

Restores the input text from a previously saved state.

ParameterTypeDescription
datatableState table containing the saved text.