Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!