Take a look at the onCreateYesNoDialog() method in MyCanvas.java 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.
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”.
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.