API Docs

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

Set additional informative text below the main message
informativeText(text) -> HSUIDialog
Name Type Description
text string The informative text
HSUIDialog
Self for chaining
hs.ui.dialog("Save?").informativeText("Unsaved changes").show()

buttons(labels) -> HSUIDialog

Set custom button labels
buttons(labels) -> HSUIDialog
Name Type Description
labels string[] Array of button labels (default: ["OK"])
HSUIDialog
Self for chaining
hs.ui.dialog("Save?").buttons(["Save", "Discard", "Cancel"]).show()

style(style) -> HSUIDialog

Set the dialog style
style(style) -> HSUIDialog
Name Type Description
style string Style name (e.g., "informational", "warning", "critical")
HSUIDialog
Self for chaining
hs.ui.dialog("Delete?").style("critical").show()

onButton(callback) -> HSUIDialog

Set the callback for button presses
onButton(callback) -> HSUIDialog
Name Type Description
callback JSValue Function receiving button index (0-based)
HSUIDialog
Self for chaining
hs.ui.dialog("Confirm?")
    .onButton((i) => console.log("button", i))
    .show()

show() -> HSUIDialog

Show the dialog
show() -> HSUIDialog
HSUIDialog
Self for chaining
hs.ui.dialog("Hello").show()

close() -> None

Close the dialog programmatically
close() -> None
None
const d = hs.ui.dialog("Hello").show()
d.close()