Hi, I’m liking Corona SDK amd Lua a lot. Been reading and experimenting with creating buttons but the procedure takes too many lines considering a page/scene with multiple buttons.
So I created a function that I can call with one line and it creates the buttons for me, I choose to create diff alternatives of the Twitter Bootstrap like framework (I mean the graphical part, how they look) and it works. But there is something I can’t solve… keeping the onliner to create the button and custom event. I read I can’t change the properties once the button has been created. Well this is what I have and it works, let me try to explain:
local botonhrPress = function( event ) t.text = "Button 1 pressed" end cbutton = function (nbutton, tbutton, blabel, bfs, bx, by) bfcolor={default = { 51, 51, 51, 215 }} local button1 = widget.newButton { defaultFile = 'assets/' .. tbutton .. '.png', overFile = 'assets/o' .. tbutton .. '.png', label = blabel, labelColor = bfcolor, fontSize = bfs, emboss = true, onPress=botonhrPress } button1.x = bx; button1.y = by end
PLEASE do not mind the details, just focus on the onPress = XXXXXX. Everything else works passsing the parameters to the function and it creates the buttons, but can’t make the event work. It works writing it directly inside the function and {}, but it doesn’t work passing parameters with the name of the corresponding function for the button. Tried placing a variable with the parameter… nope, is there some kind of operators? I now some languages expect an object-like thing and not a variable with a string, some use an &, some work using parentesis.
Any ideas will be helpful, have no problem sharing the code, but it doesn’t fully work by now (for that bit only).
Thanks