From 4a797a4226893b382ffc3c1f92e844f6743c7220 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 20 Oct 2018 14:05:30 -0400 Subject: Added more documentation Added documentation for several gui elements also moved documentation of generic iguielements to an iguielement class Also added a setvisible() function to iguielements --- src/client/lua_api/gui/iguicheckbox.cpp | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/client/lua_api/gui/iguicheckbox.cpp') 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}, }; -- cgit v1.2.3-70-g09d2