HSUITextPrompt
TypeHSUITextPrompt
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
Declaration
informativeText(text) -> HSUITextPrompt
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The informative text |
Returns
HSUITextPrompt
Self for chaining
Example
hs.ui.textPrompt("Name?").informativeText("Enter your full name").show()
defaultText(text) -> HSUITextPrompt
Set the default text in the input field
Declaration
defaultText(text) -> HSUITextPrompt
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | Default text value |
Returns
HSUITextPrompt
Self for chaining
Example
hs.ui.textPrompt("Name?").defaultText("Anonymous").show()
buttons(labels) -> HSUITextPrompt
Set custom button labels
Declaration
buttons(labels) -> HSUITextPrompt
Parameters
| Name | Type | Description |
|---|---|---|
| labels | string[] | Array of button labels (default: ["OK", "Cancel"]) |
Returns
HSUITextPrompt
Self for chaining
Example
hs.ui.textPrompt("Confirm?").buttons(["Yes", "No"]).show()
onButton(callback) -> HSUITextPrompt
Set the callback for button presses
Declaration
onButton(callback) -> HSUITextPrompt
Parameters
| Name | Type | Description |
|---|---|---|
| callback | JSValue | Function receiving (buttonIndex, inputText) |
Returns
HSUITextPrompt
Self for chaining
Example
hs.ui.textPrompt("Name?")
.onButton((idx, text) => console.log(idx, text))
.show()
show() -> None
Show the prompt dialog
Declaration
show() -> None
Returns
None
Example
hs.ui.textPrompt("Name?").show()