API Docs

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) -> HSUITextPrompt

Set additional informative text below the main message
informativeText(text) -> HSUITextPrompt
Name Type Description
text string The informative text
HSUITextPrompt
Self for chaining
hs.ui.textPrompt("Name?").informativeText("Enter your full name").show()

defaultText(text) -> HSUITextPrompt

Set the default text in the input field
defaultText(text) -> HSUITextPrompt
Name Type Description
text string Default text value
HSUITextPrompt
Self for chaining
hs.ui.textPrompt("Name?").defaultText("Anonymous").show()

buttons(labels) -> HSUITextPrompt

Set custom button labels
buttons(labels) -> HSUITextPrompt
Name Type Description
labels string[] Array of button labels (default: ["OK", "Cancel"])
HSUITextPrompt
Self for chaining
hs.ui.textPrompt("Confirm?").buttons(["Yes", "No"]).show()

onButton(callback) -> HSUITextPrompt

Set the callback for button presses
onButton(callback) -> HSUITextPrompt
Name Type Description
callback JSValue Function receiving (buttonIndex, inputText)
HSUITextPrompt
Self for chaining
hs.ui.textPrompt("Name?")
    .onButton((idx, text) => console.log(idx, text))
    .show()

show() -> None

Show the prompt dialog
show() -> None
None
hs.ui.textPrompt("Name?").show()