PDA

View Full Version : Create buttons on the fly from LUA?



tmorten
June 3rd, 2007, 08:26 AM
Is there a way to create (and perhaps later destroy) a new button at run-time from LUA? I'd like to be able to add unanticipated buttons on the basis of data sent from Girder. If there were a way on the NetRemote side to create buttons from LUA, this would be possible. Ideally I would be able to specify screen coordinates, up/down images (if any), dimensions (if it's not an image), text (if any), and perhaps a function to call when button is pressed.

Thanks,
Tim

Rob H
June 3rd, 2007, 09:25 AM
Not yet, no - I wish there were. You can fake some of it, by precreating the buttons in NRD, but offscreen. Then at runtime you could move them to the appropriate position onscreen. If you had related buttons then you could do the same with a hidden panel containing the buttons and show/move it as appropriate.

As far as the actions go then providing Lua actions are suitable there are a number of possibilities, depending on how far you want to go. Most, if not all of these would probably be a complete swine to debug though.

tmorten
June 3rd, 2007, 09:44 AM
Fair enough; is there a way to set the button text on the fly?

Rob H
June 3rd, 2007, 10:07 AM
Yes, just use an NR variable name in braces as per usual

tmorten
June 3rd, 2007, 10:15 AM
Right; silly me (I do that all over the place already). :)