In OSX vtk window does not get the focus - continued

After the nabble mailing list has been shut down, I’d like to continue the discussion about the window-to-front issue on MacOS here on discourse…

Preceding discussion:

On MacOS, the render window is not shown on top. The problem can be easily reproduced, use for example this hello world example.

As David mentioned, one has to interfere with Cocoa framework to fix this. Fumbling around with pyobjc helped me to show the render window on top. Add the following couple of lines just before iren.Start(), and the window will go on top.

    import os 
    from Cocoa import NSRunningApplication, NSApplicationActivateIgnoringOtherApps
    pid = os.getpid()
    x = NSRunningApplication.runningApplicationWithProcessIdentifier_(pid)


The last missing piece is how grab the keyboard focus on show. The interactor does not immediately receive the keyboard focus on show. A user still has to click inside the render window for the keyboard events to be handled.

I anyone has an idea how to fix this, I’d be happy to know.