Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
How to console.log into new created window (Not main window) in Electron?

So I have an application where I create new window on button click. And now I would like to add some event listener on that new window (to write something in console), but it just does not work. How can I trigger that event listener on a new window, after new window is created on button click?

My code from one of js files:

const { BrowserWindow } = require('@electron/remote')
const remote = require('@electron/remote/main')

//Creating new window

let secondWindow = new BrowserWindow({
  kiosk:false,
  frame:true,
  show:false,


})

// On mouse click on main window show new window (secondWindow)

window.addEventListener('mousedown', function(event) {
  
  secondWindow.show();
  secondWindow.focus();
  secondWindow.webContents.openDevTools()


})

// And now i can't do this:
secondWindow.addEventListener('mousedown', function(event) {
  
  console.log('Second window click')


})

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

As per the documentation, you should make sure that the BrowserWindow is ready before you attach the event listener to it.

If the BrowserWindow is not ready you will be trying to attach an event to an undefined container.

Check the docs for more infos

const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ show: false })
win.once('ready-to-show', () => {
    win.show()
    // attach your event here
})
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda