# nUIEventCallback method

**URL:** <https://techcommunity.softwareag.com/t/nuieventcallback-method/100298>\
**Category:** Forum\
**Tags:** mobile\
**Created:** [January 24, 2012, 2:09pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298 "2012-01-24T14:09:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 24, 2012, 2:09pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/1 "2012-01-24T14:09:12Z")

</div>

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?

Thanks  
Atanas

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [January 24, 2012, 3:43pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/2 "2012-01-24T15:43:32Z")

</div>

Hi Atanas,

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.

Kind regards,  
Rikki

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 24, 2012, 4:32pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/3 "2012-01-24T16:32:21Z")

</div>

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”.

Thanks,  
Nenko

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [January 24, 2012, 4:48pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/4 "2012-01-24T16:48:52Z")

</div>

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,  
Rikki

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 24, 2012, 4:51pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/5 "2012-01-24T16:51:46Z")

</div>

Yep, I overlooked this.

Thanks again

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:01pm UTC](https://techcommunity.softwareag.com/t/nuieventcallback-method/100298/6 "2021-04-02T15:01:50Z")

</div>


