X Tutup
Skip to content

Commit fe47625

Browse files
📝 Document the progress bar
1 parent c3362c7 commit fe47625

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/tutorial/progress-bar.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Progress Bar in Taskbar (Windows, macOS, Unity)
2+
3+
On Windows a taskbar button can be used to display a progress bar. This enables
4+
a window to provide progress information to the user without the user having to
5+
switch to the window itself.
6+
7+
On macOS the progress bar will be displayed as a part of the dock icon.
8+
9+
The Unity DE also has a similar feature that allows you to specify the progress
10+
bar in the launcher.
11+
12+
__Progress bar in taskbar button:__
13+
14+
![Taskbar Progress Bar][taskbar-progress-image]
15+
16+
All three cases are covered by the same API - the `setProgressBar()` method
17+
available on instances of `BrowserWindows`. Call it with a number between `0`
18+
and `1` to indicate your progress. If you have a long-running task that's
19+
currently at 63% towards completion, you'd call it with `setProgressBar(0.63)`.
20+
21+
Generally speaking, setting the parameter to a value below zero (like `-1`)
22+
will remove the progress bar while setting it to a value higher than one
23+
(like `2`) will switch the progress bar to intermediate mode.
24+
25+
See the [API documentation for more options and modes][setprogressbar].
26+
27+
```javascript
28+
const { BrowserWindow } = require('electron')
29+
const myWindow = new BrowserWindow()
30+
31+
win.setProgressBar(0.5)
32+
```
33+
34+
[taskbar-progress-image]: https://cloud.githubusercontent.com/assets/639601/5081682/16691fda-6f0e-11e4-9676-49b6418f1264.png
35+
[setprogressbar]: ../api/browser-window.md#winsetprogressbarprogress

0 commit comments

Comments
 (0)
X Tutup