HSUIAlert
Type
HSUIAlert
A temporary on-screen notification
Displays a message that automatically fades out after a specified duration. Positioned in the center of the screen with a semi-transparent background.
Example
hs.ui.alert("Task completed!")
.font(HSFont.headline())
.duration(5)
.padding(30)
.show();
Properties
This type has no properties.
Methods
font(font)
Set the font for the alert text
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:33
Parameters
-
fontHSFontAn HSFont object (e.g., `HSFont.headline()`)
Returns
HSUIAlert - Self for chaining
duration(seconds)
Set how long the alert is displayed
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:38
Parameters
-
secondsnumberDuration in seconds (default: 5.0)
Returns
HSUIAlert - Self for chaining
padding(points)
Set the padding around the alert text
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:43
Parameters
-
pointsnumberPadding in points (default: 20)
Returns
HSUIAlert - Self for chaining
position(dict)
Set a custom position for the alert
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:48
Parameters
-
dict{[key: string]: any}Dictionary with `x` and `y` coordinates
Returns
HSUIAlert - Self for chaining
show()
Show the alert
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:52
Parameters
None
Returns
HSUIAlert - Self for chaining (can store reference to close manually)
close()
Close the alert immediately
Hammerspoon 2/Modules/hs.ui/Dialogs/HSUIAlert.swift:55
Parameters
None
Returns
Nothing