I have a java app which creates a Canvas and uses JNI to pass the HWND to native Win32 code (it's used as a render target). Everything was working fine and dandy until I updated to Java 7 (1.7.0)...
Previously, all mouse wheel and keyboard presses over the Canvas were passed directly to the native HWND. Since updating to 1.7.0, however, these events get passed to the Canvas object and never reach my native code :-( Mouse clicks and movement work as before.
Has anyone else seen this behaviour? Any suggestions on how to work around this issue?
Fix seems obvious: in stead of relying on the windows messaging, facilitate it yourself through the JNI interface by propagating events you catch on the java side to the native logic. That will probably incur a slight performance hit of course, but you lose the dependency on internal mechanisms.
Thanks for the reply. Yes, what you describe would work around the problem, but I thought of that as a 'brute force' approach :-) My application has been working the same way for years, so I'd prefer to try and find a simpler fix for it.
After a bit of research, I think the issue could be due to changes in how focus is handled for JDK 7:
The Canvas that was used for native rendering didn't receive any mouse events; they appeared to be lost somehow. Although my native CView-derived class didn't receive focus events, I noticed that CView::OnMouseActivate() was still being called when I clicked on the Canvas. I overrode this function and added a call to SetFocus(), which was enough to cause mouse wheel and keyboard messages to be passed to my native View.