Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

390
Visualizações
Electron Uncaught Exception: TypeError: Cannot read properties of null (reading 'on')

The error appears only if i open a new window when the inspector is opened once. It does'nt appear for mainWindow.

enter image description here

// Detect maximize-unmaximize to change the maximize button's icon
app.on('browser-window-focus', (event, win) => {
  console.log('Focus: ' + win.webContents.id);
  BrowserWindow.fromId(win.webContents.id).on('ready-to-show', () => {
    BrowserWindow.fromId(win.webContents.id).on('maximize', () => {
      console.log("maximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'maximize');
    })
    BrowserWindow.fromId(win.webContents.id).on('unmaximize', () => {
      console.log("unmaximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'unmaximize');
    })
  })
})
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This happens because you are using the same webview instance of your browser windows. You can fix this by creating a separate webview in each window and then use that instead. For example, try changing it as follows:

var myBrowser = require('electron').remote.getGlobal('Browser'); var myBrowser2 = require('electron').remote.getGlobal('Browser2');

myBrowser.webContents.on('dom-ready', function(){ myBrowser2.webContents.send('window-events', 'maximize') }); myBrowser2.webContents.on('dom-ready', function(){ myBrowser.webContents.send('window-events', 'unmaximize') });

You will need to make sure that both windows have their own unique id so that they do not conflict with one another. Also note that I am assuming you want to send these events from within the renderer process itself. If you would like to receive them on the main process side, you should be able to listen for "window-events" on the remote object returned by getGlobal.

about 4 years ago · Juan Pablo Isaza Relatório

0

I solved the problem with using .getFocusedWindow() instead of .fromId. Thank you.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda