nUIEventCallback method

Hi All,

Is there an easy way to make every object register its own callback method which will be called for its own type of events?

In the samples the callback method is registered for MainCanvas and it is called for all object events?


Hi Atanas,

Take a look at the onCreateYesNoDialog() method in of the NativeUI Demo sample. It demonstrates how you can add a custom event listener to any descendant of nUIObject.

Your listener needs to implement the nUIEventListener interface, and then you need to call .addEventListener() on the object you want to handle the events for.

Kind regards,

Hi Rikki,
Thanks for the response. Can you explain what is the second parameter of nUIObject#addEventListener? From the javadoc I understande that if it’s true than only the specified listener will be called and not the generic one (I suppose this is the Canvas) , however when I add “System.out.println” in the MyCanvas#nUIEventCallback is gets called nevertheless “exclusive” param is true|false for the “YesNoDialog”.


Hi Nenko,

The reason the event gets through to the MyCanvas#nUIEventCallback is because AlternateEventListener passes the event onto the dialog’s parent class (which is MyCanvas).

If you remove the call to parent.nUIEventCallback(object, evt_type), then you will see the ‘exclusive’ parameter of addEventListener behaving as you expect.

Kind regards,

Yep, I overlooked this.

Thanks again