G4P - Specifying Listener Method

I’m a new user of G4P, migrating over from ControlP5. I’m coding my app as native java classes (but still using the Processing 3 IDE). I am simply trying to assign a listener to a specific button control via .addEventHandler( PApplet sketch, String methodName ). This is being called from within one of my classes. The issue I run into is how to specific the name of the listener method since it is defined in my class and not the top level class. I’ve tried fully qualifying the method name but that doesn’t seem to help. And FWIW, I had the same issue in ControlP5 but that library also provides addCallback() methods that allow for listeners to be passed in as objects that implement ControlP5’s ‘listener’ interface, or also as inline anonymously defined listener objects. I am not yet seeing a similar facility in G4P, although again I am new to this library.

Also, in G4P can one setup a listener not just on a specific control but also for a specific type of event? I know that one can code the filtering within their listener but I’m hoping there’s a way to somehow offloaded it to the event framework, like in ControlP5. Thanks in advance :slight_smile:

1 Like

The question posed in the first paragraph seems to be basically the same as the question in your second post which I have answered so I suggest you look there for an answer.

No but you can test the event type inside the event handler e.g.
if(event == GEvent.CLICKED) { // do something

1 Like