HSUITextPrompt
Type
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.
Example
hs.ui.textPrompt("Enter your name")
.informativeText("Please provide your full name")
.defaultText("John Doe")
.buttons(["OK", "Cancel"])
.onButton((buttonIndex, text) => {
if (buttonIndex === 0) {
print("User entered: " + text);
}
})
.show();
Properties
This type has no properties.
Methods
informativeText(text)
Set additional informative text below the main message
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUITextPrompt.swift:37
Parameters
-
textstringThe informative text
Returns
HSUITextPrompt - Self for chaining
defaultText(text)
Set the default text in the input field
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUITextPrompt.swift:42
Parameters
-
textstringDefault text value
Returns
HSUITextPrompt - Self for chaining
buttons(labels)
Set custom button labels
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUITextPrompt.swift:47
Parameters
-
labelsstring[]Array of button labels (default: ["OK", "Cancel"])
Returns
HSUITextPrompt - Self for chaining
onButton(callback)
Set the callback for button presses
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUITextPrompt.swift:52
Parameters
-
callbackJSValueFunction receiving (buttonIndex, inputText)
Returns
HSUITextPrompt - Self for chaining
show()
Show the prompt dialog
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUITextPrompt.swift:55
Parameters
None
Returns
Nothing