HSUITextPrompt

A modal dialog with text input

Shows a blocking dialog with a text input field. The callback receives both the button index and the entered text.

Example

hs.ui.textPrompt("Enter your name")
    .informativeText("Please provide your full name")
    .defaultText("John Doe")
    .buttons(["OK", "Cancel"])
    .onButton((buttonIndex, text) => {
        if (buttonIndex === 0) {
            print("User entered: " + text);
        }
    })
    .show();

Properties

This type has no properties.

Methods

informativeText(text)

Set additional informative text below the main message

Parameters

  • text string

    The informative text

Returns

HSUITextPrompt - Self for chaining

defaultText(text)

Set the default text in the input field

Parameters

  • text string

    Default text value

Returns

HSUITextPrompt - Self for chaining

buttons(labels)

Set custom button labels

Parameters

  • labels string[]

    Array of button labels (default: ["OK", "Cancel"])

Returns

HSUITextPrompt - Self for chaining

onButton(callback)

Set the callback for button presses

Parameters

  • callback JSValue

    Function receiving (buttonIndex, inputText)

Returns

HSUITextPrompt - Self for chaining

show()

Show the prompt dialog

Parameters

None

Returns

Nothing