addEventListener to a table instance

Hi,

I’m having trouble with adding a litener to a table. Is it that corona listeners only work with display objects?

here’s the code

[lua]

local Ia={}

Ia:addEventListener(“name”)

[/lua]

and this is the error.

selectionMenu.lua:224: attempt to call method ‘addEventListener’ (a nil value)

Thanks!

Why would you add an event listener to a table?   Surely they should be added to objects, not tables

The table represents a class. By means of passing out information I’d like to use the listener method.

Did you manage to solve this? I’m trying to do a similar thing where it adds a listener to a randomly picked image in the table.

Acording to docs, the object:addEventListener function is bound to a class called EventListener, but I haven’t found a way to create it from scratch.

The simplest way I can think to achieve what you want is instead of having a table as your base object, having a display.newGroup(). That object inherits from EventListener and you’ll be able to add events to it.

Why would you add an event listener to a table?   Surely they should be added to objects, not tables

The table represents a class. By means of passing out information I’d like to use the listener method.

Did you manage to solve this? I’m trying to do a similar thing where it adds a listener to a randomly picked image in the table.

Acording to docs, the object:addEventListener function is bound to a class called EventListener, but I haven’t found a way to create it from scratch.

The simplest way I can think to achieve what you want is instead of having a table as your base object, having a display.newGroup(). That object inherits from EventListener and you’ll be able to add events to it.