Skip to content

Instantly share code, notes, and snippets.

@oysteinmoseng
Created November 9, 2019 16:43
Show Gist options
  • Save oysteinmoseng/bec736b1c2ceec3fa6e5a77d46d3ac08 to your computer and use it in GitHub Desktop.
Save oysteinmoseng/bec736b1c2ceec3fa6e5a77d46d3ac08 to your computer and use it in GitHub Desktop.
Electron VoiceOver issue
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
const {app, Tray, BrowserWindow, nativeImage } = require('electron')
let mainWindow
function createTray () {
const dataURL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
icon = nativeImage.createFromDataURL(dataURL).resize({ width: 16, height: 16 })
tray = new Tray(icon);
['double-click', 'click'].forEach(
e => tray.on(e, () => mainWindow.show())
)
}
function init () {
mainWindow = new BrowserWindow({
width: 200,
height: 200,
show: false // Hide until tray icon clicked
})
mainWindow.loadFile('index.html')
createTray()
}
app.on('ready', init)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
init()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment