Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Using 2.0b7 P3D with contributed libraries

$
0
0
It appears that this problem was reported as an issue but unfortunately I only scanned the outstanding issues so missed it because it had been closed (issue 1437)

It seems to me that this is going to be an ongoing problem for a while until the library authors find time to modify their code to handle the new Proccessng event model.

Looking at the source code it appears that the processing.Event class has an attribute:-
  1. protected Object nativeObject;

and the method getNative to retrieve it.

  1. /**
  2. * Get the platform-native event object. This might be the java.awt event
  3. * on the desktop, though if you're using OpenGL on the desktop it'll be a
  4. * NEWT event that JOGL uses. Android events are something else altogether.
  5. * Bottom line, use this only if you know what you're doing, and don't make
  6. * assumptions about the class type.
  7. */
  8. public Object getNative() {
  9.       return nativeObject;
  10. }

Currently the G4P library uses the registerMouseEvent, registerKeyEvent methods to capture the AWT mouse and keyboard events then forwards them to the various GUI controls.

My idea is to use the new methods register("mouseEvent", this) to capture the Processing events  then forward the native object onto the controls.

This solution (for desktop applications) is simple to implement provided that the native objects inside the Processing event match their AWT counterparts i.e.

Processing Event
      Native object
MouseEvent
                        java.awt.event.MouseEvent
KeyEvent     
                java.awt.event.KeyEvent

Does anyone know whether this is the casse for all renderers. The comments suggest that OpenGL on the desktop may become NEWT based.

I am not familiar with the NEWT toolkit but my research seems to indicate that the AWT and NEWT toolkits can exist side by side and in particular JOGL can work with both.

Is it the intention of the development team to replace AWT with NEWT when using P2D and P3D or can I rely on the native object mapping above?

Viewing all articles
Browse latest Browse all 1768

Trending Articles