http://blog.csdn.net/cnjet/article/details/5974212
Lua really has a lot of magical uses, and here's a table-based implementation of the GUI definition. Support incident response and so on.
You can test the run effect online (Http://www.lua.org/cgi-bin/demo).
[CPP]View Plaincopy
- --Canvas
- Canvas = {
- ["Frame_msg. Oframe "] = {
- skin="Engine//standard.oskin1stateframe",
- image="Engine//standarddialog.otexture2d",
- left=148,
- Top=90,
- right=700,
- BOTTOM=10,
- Titlebar=false,
- Closebtn=false,
- Ontick = function (self)
- Print (Self.image)
- End
- ["BUTTON_OK. Obutton "] = {
- skin="Engine//standard.oskin3statebutton",
- image="Engine//standardbtn.otexture2d",
- font={ "Engine//harabara.otruetypefontface"},
- left=148,
- Top=90,
- right=276,
- BOTTOM=10,
- text="OK",
- onclick = function (self)
- Print ("button OK is clicked.")
- Print (Self.text)
- Self.text = "Cancel"
- Print (Self.text)
- End
- }
- }
- }
- canvas["frame_msg. Oframe "]:ontick ()
- canvas["frame_msg. Oframe "[" BUTTON_OK. Obutton "]:onclick ()
A more detailed tutorial:
Http://lua-users.org/wiki/ObjectOrientationTutorial
Table-based LUA native support for object-oriented programming in GUI use example