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

106
Vistas
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
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