G
G
g1tufix2020-06-21 08:07:19
JavaScript
g1tufix, 2020-06-21 08:07:19

How to close the Electron window?

Hello. I made the client using Electron.js. The created window has the following parameters:
width: 600,
height: 400,
frame: false,
resizable: false,
so I did mainWindow.setMenuBarVisibility(false) to turn off the menu
, I have a problem - I can't make a button to close the window. I need to save frame:false , which means I need to make my own button. I tried window.close , hide , app.quit but nothing helped. Is there a solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mazino, 2020-06-21
@Mazino

In theory, anywhere except the main file:

const { remote } = require('electron')
remote.getCurrentWindow().close()

in main file instead of remote you have app.
there should be code like this
win.on('closed', () => {
    win = null
})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

R
rPman, 2020-06-21
@rPman

weird, app.quit should have worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question