Getting self from ui.button onRelease callback

First post on forum. I was a previous DragonFire user (released 2 games using it).

Now I’m exploring corona.

I’ve 1 problem here. I’ve done the research but couldn’t find anything i need.

Basically I’ve created a pool of buttons for my level selection menu.

  
local levelSelected = function()  
  
end  
  
local createLevelSelectionGUI = function(levelPack)  
 for i=0,4 do  
 for j=0,2 do  
 local tempLevelBtn = ui.newButton{  
 default = "btnLevel1.png",  
 over = "btnLevel2.png",  
 onRelease = levelSelected,  
 text = string.format("%u", levelCount),  
 emboss = true  
 }  
 end  
 end  
end  

As you can see all these buttons link to levelSelected function onRelease event.

My idea is to access the text property of the button clicked and load the appropriate level.

But how can I access the source button when my levelSelected function is being called?

Thanks [import]uid: 7995 topic_id: 5501 reply_id: 305501[/import]

event listeners have a parameter for information about the event:

local levelSelected = function(event) print(event) print(event.target) print(event.phase) end [import]uid: 12108 topic_id: 5501 reply_id: 18589[/import]

Hi

Thanks. Now I can see the text property inside the button object.

But that text is a table and I can’t get the actual label in the button.

Any idea? [import]uid: 7995 topic_id: 5501 reply_id: 18713[/import]