Reputation: 41
I want to create an application that can't be closed by task manager. I do prevent application closing from taskbar, minimize the window and put it in tray but couldn't handle task manager closing. I'm wondering if anyone could help me.
Here's the snippet:
mainWindow.on('close', (event) => {
if (!canClose) {
event.preventDefault();
mainWindow.minimize();
mainWindow.setSkipTaskbar(true);
} else {
if (appIcon) appIcon.destroy();
app.quit();
}
});
canClose => let, appIcon => Tray
Upvotes: 1
Views: 1524
Reputation: 4854
app.on('before-quit', event => {
event.preventDefault();
})
before-quit
event will be triggered just before quit
event.
Prevent this event manually then quit
event won't be triggered.
Upvotes: 1