GLCanvas and keyboard focus with Mac Os

We’ve been porting our app to Mac Os this week and apart from a few minor issues, the main hurdle we have hit involves differences between how keyboard focus is handled on Windows and Mac.

The basic structure has a GLCanvas as the content pane of a JFrame with a 2D control panel laid over it. On Windows, the keyboard events correctly go to the appropriate controls but not on a Mac. The mouse events work fine however. As a debug we’ve been printing out the current focus owner as reported by the KeyboardFocusManager whenever a mouse click is received (and after the mouse event has been handled). On Windows it reports the components as expected, but on the Mac it is always null.

Can anyone tell me what differences there are between Windows and Mac in this area? Is this a difference in behaviour between the implementations of GLCanvas?

Thanks,
Dave

GLCanvas is shared code. There is nothing different in the implementation of the OpenGL-related code that is related to event dispatching.

What happens if you replace the GLCanvas with a normal Canvas? Do you see the same behavior?

You may have come across a bug in Apple’s implementation of the AWT. Have you tried using requestFocus() manually?

What version of OS X with what version of Java?

Check this for known issues with Mac OS X Java 5 R4

http://developer.apple.com/releasenotes/Java/Java50Release4RN/index.html