widget.newButton Events - What The Heck?????

Ok so im going through replacing my ui.buttons with widget.newButton, and for some reason it seems that the events ( onPress, onEvent, onRelease ) only support the event, parm with just a few properties.

And it has no self parm so if i wanted to make a 1 generic listener for 3 buttons and check that event and decided which one was clicked, I can not.

Do I really have to assign a different listener event for each button??

1/2 of the corona API’s use (self,event) the over have (event) and some other set of parms.

I would be nice if we could make a standard and stick with it.

It’s getting very upsetting to try to figure things again and again out all of the time.

SO - Do I really have to assign a different listener event for each button?? Or am I doing something wrong? Can you please specify this info in your API doc, because if its there I missed it.

Larry
[import]uid: 11860 topic_id: 20187 reply_id: 320187[/import]

buttons have an “id” parameter.

local pauseButton = widget.newButton{  
 id = "pause",  
 left = 100,  
 top = 200,  
 label = "Pause",  
 onRelease = buttonHandler  
}  

and in the buttonHandler:

[code]
local buttonHandler = function(event)

if event.id == “pause” then
–do stuff
elseif event.id == “quit” then
–do stuff
end
[/code] [import]uid: 120 topic_id: 20187 reply_id: 78840[/import]

I tried that and for some reason I kept getting errors just trying to print it out said it had said it had a nil value but it did not.

print (“onPress–>>” … event.id )

Thats why im going crazy…

Larry [import]uid: 11860 topic_id: 20187 reply_id: 78845[/import]

Can you paste some of the code that is giving you errors? [import]uid: 120 topic_id: 20187 reply_id: 78850[/import]

Sorry I got side tracked but I am back on this.

After digging into it even more it looks like this is what you need to do to access the custom property

Notice event.target.(whatever)

local buttonHandler = function(event)  
   
 if event.target.id == "pause" then  
 --do stuff  
 elseif event.target.id == "quit" then  
 --do stuff  
 end  
  
end  

Thanks for the assist.

Larry Meadows [import]uid: 11860 topic_id: 20187 reply_id: 80021[/import]