Login  Register

Re: GLJPanel/GLCanvas dpi scaling and AWT pointer coordinates

Posted by gouessej on Jul 07, 2024; 1:34am
URL: https://forum.jogamp.org/GLJPanel-GLCanvas-dpi-scaling-and-AWT-pointer-coordinates-tp4043482p4043492.html

Sorry I took the problem in the wrong direction, you're right.

I'm not sure that my solution is suitable for your use case but could you use NEWT mouse listener instead? Actually, the AWTMouseAdapter allows to build an AWT MouseListener,  an AWT MouseMotionListener and an AWT MouseWheelListener from a single NEWT mouse listener but you seem to need to do the opposite. The documentation of isAWTEventPassThrough() indicates that only the NEWT child receives the key and mouse input events, it seems to be consistent with what you observed. I fear that adding an AWTMouseAdapter to the NewtCanvasAWT will lead nowhere. I see two options:
- write a NEWT mouse listener and add it into the NEWT child of the NewtCanvasAWT (you already know that it works)
- write a utility that builds a single NEWT mouse listener from an AWT MouseListener,  an AWT MouseMotionListener and an AWT MouseWheelListener and add it into the NEWT child of the NewtCanvasAWT

Personally, I would choose the first option, it would drive your listener AWT agnostic, you could still use it with NEWT and AWT. The second option is doable but you would introduce AWT event management's limitations into NEWT, you should make a request for enhancement about this subject, maybe I can help you to write the necessary class to do that, it would help the transition from AWT to NEWT because we could use the resulting class in NewtCanvasAWT so that you could simply add an AWT mouse listener to it and it would work but I'm sure that there is a reason why it wasn't designed that way.

Sven, what's your opinion about that?
Julien Gouesse | Personal blog | Website