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

100
Views
Electronjs prevent child window drag to another screen

I would like to prevent moving child window to another screen.

Reason: Because there is a bug on macOS. When I drag child window to a different screen than parent window is, the child window disappears.

So I would like to prevent this, but I am not able to achieve it in some nice way. moved event is alis for move event on mac, so it is triggered quite often and window is jumping when it is dragged to another screen.

I have tried will-move, but it is triggered just once in the beginning.

My code:

childWindow.on('moved', () => { // Same as `move` on mac
  const bounds = childWindow.getBounds();
  const currentDisplay = screen.getDisplayNearestPoint({
    x: bounds.x,
    y: bounds.y,
  });

  const parentBounds = childWindow.getParent().getBounds();
  const parentDisplay = screen.getDisplayNearestPoint({
    x: parentBounds!.x,
    y: parentBounds!.y,
  });

  if (currentDisplay.id !== parentDisplay.id) {
    childWindow.setBounds({ x: 0, y: 0 }); // Here I can center the window or set proper x, y. This is just for testing purposes.
  }
});
about 4 years ago · Santiago Trujillo
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!