I’m new to Lua, Corona, and event-driven programming in general, working on my very 1st project, so apologies in advance for the newbie question and if I botch up terminology. Also, I’m currently still just a Trial, for Corona.
Question #1: I created a bunch of buttons with: local button = ui.newButton {…} (obviously, different variables were used for each button)
Within the same scope as the button creation, all of the buttons used the same button handler. The button handler properly registered button events.
However, within the button handler, button:removeSelf() did NOT work.
But it DID work, if the button was created WITHOUT the “local”, suggesting that even though the button creation and the button handler were in the same scope, I needed to create the button as a global.
Is this expected behavior? And if so, why? (Because, if I create a test local variable in the same place as the button creation, that variable IS visible within the button handler.)
===========
Question #2: after using ui.newButton-created buttons, is there a way to change the “default” and “over” images to be used?
For example, at certain times, I’d like the buttons to be “grayed out” and not pressable. One way I thought I could do that would be to change the button so that both the default and over images point to the same grayed-out image, and have the event handler ignore press/releases.
Is this possible?
If not, is the best way to implement this to removeSelf() the button, and then recreate it with the two grayed-out images, and not give it an event handler? And then, when the button should be “active” again, removeSelf() the inactive buttons and recreate the functioning buttons?
Thanks in advance for tips / advice.
[import]uid: 37155 topic_id: 13499 reply_id: 313499[/import]