HSUIDialog
TypeHSUIDialog
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
Declaration
informativeText(text) -> HSUIDialog
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The informative text |
Returns
HSUIDialog
Self for chaining
Example
hs.ui.dialog("Save?").informativeText("Unsaved changes").show()
buttons(labels) -> HSUIDialog
Set custom button labels
Declaration
buttons(labels) -> HSUIDialog
Parameters
| Name | Type | Description |
|---|---|---|
| labels | string[] | Array of button labels (default: ["OK"]) |
Returns
HSUIDialog
Self for chaining
Example
hs.ui.dialog("Save?").buttons(["Save", "Discard", "Cancel"]).show()
style(style) -> HSUIDialog
Set the dialog style
Declaration
style(style) -> HSUIDialog
Parameters
| Name | Type | Description |
|---|---|---|
| style | string | Style name (e.g., "informational", "warning", "critical") |
Returns
HSUIDialog
Self for chaining
Example
hs.ui.dialog("Delete?").style("critical").show()
onButton(callback) -> HSUIDialog
Set the callback for button presses
Declaration
onButton(callback) -> HSUIDialog
Parameters
| Name | Type | Description |
|---|---|---|
| callback | JSValue | Function receiving button index (0-based) |
Returns
HSUIDialog
Self for chaining
Example
hs.ui.dialog("Confirm?")
.onButton((i) => console.log("button", i))
.show()
show() -> HSUIDialog
Show the dialog
Declaration
show() -> HSUIDialog
Returns
HSUIDialog
Self for chaining
Example
hs.ui.dialog("Hello").show()
close() -> None
Close the dialog programmatically
Declaration
close() -> None
Returns
None
Example
const d = hs.ui.dialog("Hello").show()
d.close()