Skip to content

Instantly share code, notes, and snippets.

@CharlieHess
Last active September 17, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlieHess/42ccda84409c40d6c0074e2ac409b712 to your computer and use it in GitHub Desktop.
Save CharlieHess/42ccda84409c40d6c0074e2ac409b712 to your computer and use it in GitHub Desktop.
isVisible vs isFocused
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</body>
</html>
const {app, BrowserWindow} = require('electron')
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
mainWindow.loadFile('index.html')
mainWindow.on('close', function (e) {
e.preventDefault()
mainWindow.hide()
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
const {remote} = require('electron')
const mainWindow = remote.BrowserWindow.getAllWindows()[0]
// Hidden windows will still return true for isFocused
// To see this behavior, start this fiddle and close the window immediately
setTimeout(() => {
console.log('isVisible: ', mainWindow.isVisible())
console.log('isFocused: ', mainWindow.isFocused())
mainWindow.show()
mainWindow.webContents.openDevTools()
}, 5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment