Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Editbox

Classes

Class: Editbox

Extends Widget, Editboxbase

Editbox

Warning: All methods for this class are broken. Use X2Editbox.

A Editbox widget allows users to enter and edit string or numeric values. Supports focus management, history tracking, digit-only and password modes, input validation policies, prefix text rendering, and configurable insets. Provides utilities for controlling composition state behavior, selection handling on focus, and various input constraints.

Dependencies:

Field: prefixStyle

TextStyle

The text style applied to the optional prefix text.

Method: SetInset

(method) Editbox:SetInset(left: number, top: number, right: number, bottom: number)

Sets the inset for the Editbox.

@param left — The left inset.

@param top — The top inset.

@param right — The right inset.

@param bottom — The bottom inset.

Method: SetInitVal

(method) Editbox:SetInitVal(val: number)

Sets the initial value for the Editbox.

@param val — The initial value.

Method: SetHistoryLines

(method) Editbox:SetHistoryLines(count: number)

Sets the maximum number of history lines for the Editbox.

@param count — The maximum number of history lines. (default: 0)

Method: SetFocus

(method) Editbox:SetFocus()

Sets focus to the Editbox.

Method: SetPassword

(method) Editbox:SetPassword(password: boolean)

Enables or disables password mode for the Editbox.

@param passwordtrue to enable password mode, false to disable. (default: false)

Method: SetPrefixInset

(method) Editbox:SetPrefixInset(left: number, top: number, right: number, bottom: number)

Sets the inset for the prefix text in the Editbox.

@param left — The left inset for the prefix.

@param top — The top inset for the prefix.

@param right — The right inset for the prefix.

@param bottom — The bottom inset for the prefix.

Method: SetPossibleFirstZero

(method) Editbox:SetPossibleFirstZero(possibleFirstZero: boolean)

Enables or disables allowing a leading zero in digit input.

@param possibleFirstZerotrue to allow leading zero, false to disallow. (default: false)

Method: SetReClickable

(method) Editbox:SetReClickable(click: boolean)

Enables or disables re-clickable behavior for the Editbox.

@param clicktrue to enable re-clicking, false to disable.

Method: SetPrefixText

(method) Editbox:SetPrefixText(prefixText: string)

Sets the prefix text for the Editbox.

@param prefixText — The prefix text to display.

Method: UseSelectAllWhenFocused

(method) Editbox:UseSelectAllWhenFocused(use: boolean)

Enables or disables selecting all text when the Editbox gains focus.

@param usetrue to select all text on focus, false to disable. (default: true)

Method: SetEnglish

(method) Editbox:SetEnglish(english: boolean)

Sets the English input mode for the Editbox.

@param englishtrue to enable English input mode, false to disable. (default: false)

Method: SetDigitEmpty

(method) Editbox:SetDigitEmpty(empty: boolean)

Sets whether the Editbox allows empty digit input.

@param emptytrue to allow empty input, false to disallow. (default: false)

Method: ClearString

(method) Editbox:ClearString()

Clears the string content of the Editbox.

Method: ClearFocus

(method) Editbox:ClearFocus()

Clears focus from the Editbox.

Method: CheckNamePolicy

(method) Editbox:CheckNamePolicy(nameType: `NRT_CHARACTER`|`NRT_CHAT_TAB`|`NRT_CUSTOM`|`NRT_FACTION_ROLE`|`NRT_FACTION`...(+6))

Checks the name policy for the Editbox.

@param nameType — The name type to check against.

--  api/X2Util
nameType:
    | `NRT_CHARACTER`
    | `NRT_CHAT_TAB`
    | `NRT_CUSTOM`
    | `NRT_FACTION`
    | `NRT_FACTION_ROLE`
    | `NRT_FAMILY`
    | `NRT_FAMILY_TITLE`
    | `NRT_MAX`
    | `NRT_PORTAL`
    | `NRT_ROSTER_TITLE`
    | `NRT_SUMMONS`

Method: SetDigitMax

(method) Editbox:SetDigitMax(max: number)

Sets the maximum value for digit input in the Editbox.

@param max — The maximum digit value.

Method: IsDigit

(method) Editbox:IsDigit()
  -> digit: boolean

Checks if the Editbox content is restricted to digits.

@return digittrue if restricted to digits, false otherwise. (default: false)

Method: IsPassword

(method) Editbox:IsPassword()
  -> password: boolean

Checks if the Editbox is set as a password field.

@return passwordtrue if set as password, false otherwise. (default: false)

Method: IsNowComposition

(method) Editbox:IsNowComposition()
  -> boolean

Checks if the Editbox is in a composition state (e.g., IME input).

@returntrue if in composition state, false otherwise. (default: false)

Method: SetDigit

(method) Editbox:SetDigit(digit: boolean)

Enables or disables digit-only input for the Editbox.

@param digittrue to restrict to digits, false to allow all characters. (default: false)

Method: AddHistoryLine

(method) Editbox:AddHistoryLine(text: string)

Adds a text entry to the Editbox history.

@param text — The text to add to the history.