HSUIDialog

A modal dialog with customizable buttons

Shows a blocking dialog with a message, optional informative text, and custom buttons. Use the callback to respond to button presses.

Example

hs.ui.dialog("Save changes?")
    .informativeText("Your document has unsaved changes.")
    .buttons(["Save", "Don't Save", "Cancel"])
    .onButton((index) => {
        if (index === 0) {
            print("Saving...");
        } else if (index === 1) {
            print("Discarding changes...");
        }
    })
    .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

HSUIDialog - Self for chaining

buttons(labels)

Set custom button labels

Parameters

  • labels string[]

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

Returns

HSUIDialog - Self for chaining

style(style)

Set the dialog style

Parameters

  • style string

    Style name (e.g., "informational", "warning", "critical")

Returns

HSUIDialog - Self for chaining

onButton(callback)

Set the callback for button presses

Parameters

  • callback JSValue

    Function receiving button index (0-based)

Returns

HSUIDialog - Self for chaining

show()

Show the dialog

Parameters

None

Returns

HSUIDialog - Self for chaining

close()

Close the dialog programmatically

Parameters

None

Returns

Nothing