hammerspoon2-docs
    Preparing search index...

    Class HSUIDialog

    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.

    hs.ui.dialog("Save changes?")
    .informativeText("Your document has unsaved changes.")
    .buttons(["Save", "Don't Save", "Cancel"])
    .onButton((index) => {
    if (index === 0) {
    console.log("Saving...");
    } else if (index === 1) {
    console.log("Discarding changes...");
    }
    })
    .show();
    Index

    Constructors

    Methods

    • Set custom button labels

      Parameters

      • labels: string[]

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

      Returns HSUIDialog

      Self for chaining

    • Close the dialog programmatically

      Returns void

    • Set additional informative text below the main message

      Parameters

      • text: string

        The informative text

      Returns HSUIDialog

      Self for chaining

    • Set the callback for button presses

      Parameters

      • callback: (buttonIndex: number) => void

        Function receiving the 0-based index of the button the user pressed

      Returns HSUIDialog

      Self for chaining

    • Set the dialog style

      Parameters

      • style: string

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

      Returns HSUIDialog

      Self for chaining