2019-05-06 15:29:01 +00:00
|
|
|
|
## Class: Dock
|
|
|
|
|
|
|
|
|
|
> Control your app in the macOS dock
|
|
|
|
|
|
2021-06-15 20:50:31 +00:00
|
|
|
|
Process: [Main](../glossary.md#main-process)<br />
|
|
|
|
|
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
The following example shows how to bounce your icon on the dock.
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const { app } = require('electron')
|
|
|
|
|
app.dock.bounce()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Instance Methods
|
|
|
|
|
|
|
|
|
|
#### `dock.bounce([type])` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
* `type` string (optional) - Can be `critical` or `informational`. The default is
|
2019-05-06 15:29:01 +00:00
|
|
|
|
`informational`
|
|
|
|
|
|
2019-08-23 08:16:18 +00:00
|
|
|
|
Returns `Integer` - an ID representing the request.
|
|
|
|
|
|
2019-05-06 15:29:01 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2022-01-28 20:40:20 +00:00
|
|
|
|
**Note:** This method can only be used while the app is not focused; when the app is focused it will return -1.
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
#### `dock.cancelBounce(id)` _macOS_
|
|
|
|
|
|
|
|
|
|
* `id` Integer
|
|
|
|
|
|
|
|
|
|
Cancel the bounce of `id`.
|
|
|
|
|
|
|
|
|
|
#### `dock.downloadFinished(filePath)` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
* `filePath` string
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
Bounces the Downloads stack if the filePath is inside the Downloads folder.
|
|
|
|
|
|
|
|
|
|
#### `dock.setBadge(text)` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
* `text` string
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
Sets the string to be displayed in the dock’s badging area.
|
|
|
|
|
|
|
|
|
|
#### `dock.getBadge()` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
Returns `string` - The badge string of the dock.
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
#### `dock.hide()` _macOS_
|
|
|
|
|
|
|
|
|
|
Hides the dock icon.
|
|
|
|
|
|
|
|
|
|
#### `dock.show()` _macOS_
|
|
|
|
|
|
|
|
|
|
Returns `Promise<void>` - Resolves when the dock icon is shown.
|
|
|
|
|
|
|
|
|
|
#### `dock.isVisible()` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
Returns `boolean` - Whether the dock icon is visible.
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
#### `dock.setMenu(menu)` _macOS_
|
|
|
|
|
|
|
|
|
|
* `menu` [Menu](menu.md)
|
|
|
|
|
|
|
|
|
|
Sets the application's [dock menu][dock-menu].
|
|
|
|
|
|
|
|
|
|
#### `dock.getMenu()` _macOS_
|
|
|
|
|
|
|
|
|
|
Returns `Menu | null` - The application's [dock menu][dock-menu].
|
|
|
|
|
|
|
|
|
|
#### `dock.setIcon(image)` _macOS_
|
|
|
|
|
|
2021-11-16 04:13:18 +00:00
|
|
|
|
* `image` ([NativeImage](native-image.md) | string)
|
2019-05-06 15:29:01 +00:00
|
|
|
|
|
|
|
|
|
Sets the `image` associated with this dock icon.
|
2022-12-05 18:18:57 +00:00
|
|
|
|
|
|
|
|
|
[dock-menu]: https://developer.apple.com/macos/human-interface-guidelines/menus/dock-menus/
|