diff options
Diffstat (limited to 'src/client/lua_api/gui/iguicheckbox.cpp')
| -rw-r--r-- | src/client/lua_api/gui/iguicheckbox.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/client/lua_api/gui/iguicheckbox.cpp b/src/client/lua_api/gui/iguicheckbox.cpp index 794b8f1..6413883 100644 --- a/src/client/lua_api/gui/iguicheckbox.cpp +++ b/src/client/lua_api/gui/iguicheckbox.cpp @@ -18,8 +18,15 @@ using namespace core; extern IrrlichtDevice* device; /*** +Creates a new checkbox. +Creates a new checkbox that can be checked and unchecked. Checkboxes may have the +following fields, which they will call for callbacks: + + .onCheck(self) + +It may additionally call any @{iguielement} callbacks + @function newcheckbox() -Creates a new checkbox @tparam rect dimensions The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam string default_text The default text to have in the edit box @@ -47,10 +54,35 @@ int newiguicheckbox(lua_State* L){ luaL_getmetatable(L,"gui.checkbox");//{checkbox},m{gui.checkbox} lua_setmetatable(L,-2);//{checkbox} + setelementcallback(L,EGET_CHECKBOX_CHANGED,"onCheck"); + return 1; } +//ischecked(self) +int ischecked(lua_State *L){ + lua_getfield(L,-1,"guielement"); + IGUICheckBox *e = (IGUICheckBox*)lua_touserdata(L,-1); + lua_pop(L,2); + bool checked = e->isChecked(); + lua_pushboolean(L,checked ? 1 : 0); + return 1; +} + +//setchecked(self, checked) +int setchecked(lua_State *L){ + int should = lua_toboolean(L,-1); + lua_pop(L,1); + lua_getfield(L,-1,"guielement"); + IGUICheckBox *e = (IGUICheckBox*)lua_touserdata(L,-1); + lua_pop(L,2); + e->setChecked(should == 1); + return 0; +} + static const luaL_reg iguicheckbox_m[] = { + {"ischecked", ischecked}, + {"setchecked", setchecked}, {0,0}, }; |
