Created
November 9, 2019 16:43
-
-
Save oysteinmoseng/bec736b1c2ceec3fa6e5a77d46d3ac08 to your computer and use it in GitHub Desktop.
Electron VoiceOver issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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