# Multiple render windows for vtkWasm

**URL:** https://discourse.vtk.org/t/multiple-render-windows-for-vtkwasm/14246
**Category:** Development
**Tags:** vtkwasm
**Created:** [July 16, 2024, 9:31pm UTC](https://discourse.vtk.org/t/multiple-render-windows-for-vtkwasm/14246 "2024-07-16T21:31:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [July 16, 2024, 9:31pm UTC](https://discourse.vtk.org/t/multiple-render-windows-for-vtkwasm/14246/1 "2024-07-16T21:31:55Z")

</div>

Hi Guys

I have a working setup using two `vtkWebAssembly....Windows`. It is super nasty. I stop and resume the message loop when the mouse enters a window. Here, I set all interactors to `nullptr` and set my interactor to the current window and perform some resize of the window and interactor.

It is an anti-pattern.

My question:

I will need to implement this feature and would like your feedback on my proposed design. My idea is to allow multiple windows with multiple interactors but behind the scene there is only one interactor received message and forwards them to a bunch of passive interactors (the ones that the user assigns to a window or a widget). When processing the events, I will investigate if the events lie within a canvas and use this for forwarding the interactor. I would probably also need to inject some events if the user holds the mouse button and moves from one window to another.

Another option would be to install a timer (executing in the host thread) and empty a queue with a high frequency.

Any recommendations and idea are appreciated

Jens Munk

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [September 25, 2024, 7:17pm UTC](https://discourse.vtk.org/t/multiple-render-windows-for-vtkwasm/14246/2 "2024-09-25T19:17:03Z")

</div>

A simple solution is to use `vtkGenericRenderWindowInteractor` and translate all events from JavaScript to VTK style events. Also, one needs to listen to `CreateTimerEvent` and `DestroyTimerEvent`. To do all this one needs to wrap VTK functionality to JavaScript using Emscripten.
