Class: Dock
Class: Dockβ
Control your app in the macOS dock
Process: Main
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
Instance Methodsβ
dock.bounce([type])
macOSβ
type
string (optional) - Can becritical
orinformational
. The default isinformational
Returns Integer
- an ID representing the request.
When critical
is passed, the dock icon will bounce until either the
application becomes active or the request is canceled.
When informational
is passed, the dock icon will bounce for one second.
However, the request remains active until either the application becomes active
or the request is canceled.
This method can only be used while the app is not focused; when the app is focused it will return -1.
dock.cancelBounce(id)
macOSβ
id
Integer
Cancel the bounce of id
.
dock.downloadFinished(filePath)
macOSβ
filePath
string
Bounces the Downloads stack if the filePath is inside the Downloads folder.
dock.setBadge(text)
macOSβ
text
string
Sets the string to be displayed in the dockβs badging area.
You need to ensure that your application has the permission to display notifications for this method to work.
dock.getBadge()
macOSβ
Returns string
- The badge string of the dock.
dock.hide()
macOSβ
Hides the dock icon.
dock.show()
macOSβ
Returns Promise<void>
- Resolves when the dock icon is shown.
dock.isVisible()
macOSβ
Returns boolean
- Whether the dock icon is visible.
dock.setMenu(menu)
macOSβ
menu
Menu
Sets the application's dock menu.
dock.getMenu()
macOSβ
Returns Menu | null
- The application's dock menu.
dock.setIcon(image)
macOSβ
image
(NativeImage | string)
Sets the image
associated with this dock icon.