Skip to content

Commit 58781b1

Browse files
author
Andres Pavia Marckwordt
committed
adding wording for win.focus() API
1 parent b57b84d commit 58781b1

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

assets/css/global.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ kbd {
130130
border: 0;
131131
}
132132

133+
.no-display {
134+
display: none;
135+
}
136+
133137

134138
/* Content ------------------ */
135139

renderer-process/windows/manage-window.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@ const BrowserWindow = require('electron').remote.BrowserWindow
22
const path = require('path')
33

44
const manageWindowBtn = document.getElementById('manage-window')
5+
const focusModalBtn = document.getElementById('focus-on-modal-window')
6+
let win
57

68
manageWindowBtn.addEventListener('click', function (event) {
79
const modalPath = path.join('file://', __dirname, '../../sections/windows/manage-modal.html')
8-
let win = new BrowserWindow({ width: 400, height: 275 })
9-
10+
win = new BrowserWindow({ width: 400, height: 275 })
1011
win.on('resize', updateReply)
1112
win.on('move', updateReply)
12-
win.on('close', function () { win = null })
13+
win.on('close', function () {
14+
focusModalBtn.classList.add('no-display')
15+
win = null
16+
})
1317
win.loadURL(modalPath)
1418
win.show()
15-
19+
showFocusBtn()
1620
function updateReply () {
1721
const manageWindowReply = document.getElementById('manage-window-reply')
1822
const message = `Size: ${win.getSize()} Position: ${win.getPosition()}`
1923

2024
manageWindowReply.innerText = message
25+
}
26+
function showFocusBtn () {
27+
focusModalBtn.classList.remove('no-display')
2128
}
2229
})
30+
31+
focusModalBtn.addEventListener('click', function (event) {
32+
win.focus()
33+
})
34+
35+

sections/windows/windows.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ <h2>ProTip</h2>
5151
<div class="demo-controls">
5252
<button class="demo-button" id="manage-window">View Demo</button>
5353
<span class="demo-response" id="manage-window-reply"></span>
54+
<button class="demo-button no-display" id="focus-on-modal-window">Focus on Demo</button>
5455
</div>
5556
<p>In this demo we create a new window and listen for <code>move</code> and <code>resize</code> events on it. Click the demo button, change the new window and see the dimensions and position update here, above.</p>
56-
57-
<p>There are a lot of methods for controlling the state of the window such as the size, location, and focus status as well as events to listen to for window changes. Visit the <a href="http://electron.atom.io/docs/api/browser-window">documentation<span class="u-visible-to-screen-reader">(opens in new window)</span></a> for the full list.</p>
57+
<p>Click the focus on Window button to switch focus to the modal window if it's not visible anymore.</p>
58+
<p>There are a lot of methods for controlling the state of the window such as the size and location as well as events to listen to for window changes. Visit the <a href="http://electron.atom.io/docs/api/browser-window">documentation<span class="u-visible-to-screen-reader">(opens in new window)</span></a> for the full list.</p>
5859
<h5>Renderer Process</h5>
5960
<pre><code data-path="renderer-process/windows/manage-window.js"></pre></code>
6061
</div>

0 commit comments

Comments
 (0)