electron/docs/fiddles/windows/manage-windows/window-events/renderer.js
Milan Burda 24c9cbcc0a
docs: handle opening links in the default browser in main.js (#39379)
docs: handle opening links in the default browser in the main process
2023-08-08 12:35:59 +02:00

27 lines
852 B
JavaScript

const { ipcRenderer } = require('electron')
const listenToWindowBtn = document.getElementById('listen-to-window')
const focusModalBtn = document.getElementById('focus-on-modal-window')
const hideFocusBtn = () => {
focusModalBtn.classList.add('disappear')
focusModalBtn.classList.remove('smooth-appear')
focusModalBtn.removeEventListener('click', focusWindow)
}
const showFocusBtn = (btn) => {
focusModalBtn.classList.add('smooth-appear')
focusModalBtn.classList.remove('disappear')
focusModalBtn.addEventListener('click', focusWindow)
}
const focusWindow = () => {
ipcRenderer.send('focus-demo-window')
}
ipcRenderer.on('window-focus', hideFocusBtn)
ipcRenderer.on('window-close', hideFocusBtn)
ipcRenderer.on('window-blur', showFocusBtn)
listenToWindowBtn.addEventListener('click', () => {
ipcRenderer.send('show-demo-window')
})