I’ve posted my effort here http://codea.io/talk/discussion/6847/soda-gorgeous-and-powerful-gui-windowing-button-library-for-codea#latest
Using the parent to trigger child actions is a good idea I think, I do this in the Soda library.
@UberGoober yes I think it is unavoidable, you have to have hooks into the default Codea functions setup, draw, touched, keyboard, orientationChanged in order for the library to be used. With Soda, I tried to make it so that it’s just a case of adding Soda.touched(touch), Soda.keyboard(key) etc to the end of the relevant functions.
I think we’re basically on the same page, in that the various interface components that you’re suggesting here are the same as the ones I have in Soda. IMO though having to set up the buttons with lots of methods such as :set
:ontap
setParent
etc would be much too verbose. Defining an interface would involve way too much typing! Why not use a table of keys in the constructor?
eg, my button to bring up the help page looks like this:
Soda.QueryButton{ --a button to open the help readme
parent = panel,
x = 20, y = -20,
callback = function() openURL("https://github.com/Utsira/Soda/blob/master/README.md", true) end
}
If I wanted to override the default style or shape, I add style = Soda.style.default
or whatever. The only time you can’t put something in the constructor is if the callback needs to refer to the thing itself. In those cases, you can still just define the callback outside of the constructor in standard Lua dot notation, eg:
local menu = Soda.MenuButton{x = -20, y = -20} --a button to activate the above panel
menu.callback = function() panel:show(RIGHT) menu:hide(RIGHT) end --n.b. if a callback refers to self, eg here "menu:hide", the callback has to be defined outside of the {} constructor