hammerspoon2-docs
    Preparing search index...

    Class HSUITextPrompt

    HSUITextPrompt

    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.

    hs.ui.textPrompt("Enter your name")
    .informativeText("Please provide your full name")
    .defaultText("John Doe")
    .buttons(["OK", "Cancel"])
    .onButton((buttonIndex, text) => {
    if (buttonIndex === 0) {
    console.log("User entered: " + text);
    }
    })
    .show();
    Index

    Constructors

    Methods

    • Set custom button labels

      Parameters

      • labels: string[]

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

      Returns HSUITextPrompt

      Self for chaining

    • Set the default text in the input field

      Parameters

      • text: string

        Default text value

      Returns HSUITextPrompt

      Self for chaining

    • Set additional informative text below the main message

      Parameters

      • text: string

        The informative text

      Returns HSUITextPrompt

      Self for chaining

    • Set the callback for button presses

      Parameters

      • callback: (buttonIndex: number, inputText: string) => void

        Function receiving the 0-based button index and the text the user entered

      Returns HSUITextPrompt

      Self for chaining

    • Show the prompt dialog

      Returns void