Skip to content

EditBox

Refaltor77 edited this page Mar 29, 2026 · 1 revision

EditBox

Text input field element.

Creation

use refaltor\ui\elements\EditBox;

$input = EditBox::create("my_input");

Properties

Core

$input->setTextBoxName("username_field");    // Identifier
$input->setPlaceHolderText("Enter name..."); // Placeholder text
$input->setMaxLength(32);                     // Max characters
$input->setEnabled(true);                     // Editable
$input->setTextBoxVisible(true);              // Visible
$input->setVirtual(false);                    // Virtual keyboard

Text Type

Controls which characters are allowed:

$input->setTextType(EditBox::TEXT_TYPE_EXTENDED_ASCII); // All characters
$input->setTextType(EditBox::TEXT_TYPE_IDENTIFIER_CHARS); // Letters, numbers, _
$input->setTextType(EditBox::TEXT_TYPE_NUMBER_CHARS);     // Numbers only

Colors

$input->setTextColor([1.0, 1.0, 1.0]);          // Active text color
$input->setLockedColor([0.5, 0.5, 0.5]);         // Locked/disabled color
$input->setPlaceHolderTextColor("placeholder");   // Placeholder color

Collection

$input->setTextEditBoxGridCollectionName("inputs"); // For grids
$input->setConstrainedTextEditBox("constrained");    // Constraint

Complete Example

// Username field
$username = EditBox::create("username_input")
    ->setTextBoxName("username")
    ->setPlaceHolderText("Enter your username...")
    ->setMaxLength(32)
    ->setTextType(EditBox::TEXT_TYPE_EXTENDED_ASCII)
    ->setTextColor(BasicColor::white())
    ->setSize(280, 25);

// Number-only field (world seed)
$seed = EditBox::create("seed_input")
    ->setTextBoxName("seed")
    ->setPlaceHolderText("Enter seed...")
    ->setMaxLength(20)
    ->setTextType(EditBox::TEXT_TYPE_NUMBER_CHARS)
    ->setTextColor(BasicColor::cyan())
    ->setSize(280, 25);

// Disabled field
$locked = EditBox::create("locked_input")
    ->setTextBoxName("locked")
    ->setPlaceHolderText("Read only")
    ->setEnabled(false)
    ->setLockedColor(BasicColor::rgb(0.4, 0.4, 0.4))
    ->setSize(280, 25);

See Also

Clone this wiki locally