From 80789508b9655d25629223b9dcc84b4cfb77ce45 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 29 Jun 2020 15:29:03 -0400 Subject: Updates for mdoc Also more tests --- src/client/lua_api/gui/iguicombobox.cpp | 37 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/client/lua_api/gui/iguicombobox.cpp') diff --git a/src/client/lua_api/gui/iguicombobox.cpp b/src/client/lua_api/gui/iguicombobox.cpp index 43c66f1..a9c4137 100644 --- a/src/client/lua_api/gui/iguicombobox.cpp +++ b/src/client/lua_api/gui/iguicombobox.cpp @@ -11,9 +11,6 @@ extern "C" { #include #include -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -24,10 +21,10 @@ extern IrrlichtDevice* device; Creates a new combo box. Buttons may have the following fields set for callbacks: `.onChange(self)` -@function newcombobox() +@function gui.newcombobox() @tparam rect dimensions The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguicombobox The combo box element */ //gui.newcombobox({{sx,sy},{ex,ey}}[,parent]) @@ -60,7 +57,15 @@ static int newiguicombobox(lua_State* L){ return 1; } -//{combobox}.addItem(self,text,id) +/*** +Add an item to the combo box +Adds an option to this combo box, with a given id for when it it selected +@function iguicombobox:additem(text,id) +@tparam string text The text to add to the combo box +@tparam number id The id to return from getselected() when this option is +selected +*/ +//{combobox}.add(self,text,id) int additem(lua_State *L){ int id = lua_tonumber(L,-1); lua_pop(L,1);//self,text @@ -78,6 +83,12 @@ int additem(lua_State *L){ return 0; } +/*** +Get the selected item. +Returns the number for the selected item, set with add() +@function iguicombobox:get() +@treturn number The item number that is currently selected +*/ // {combobox}.getselected(self) int getselected(lua_State *L){ lua_getfield(L,-1,"guielement");//self,ud_guielement @@ -88,7 +99,13 @@ int getselected(lua_State *L){ return 1; } -//{combobox}.removeitem(self,id) +/*** +Remove an item +Removes an item from the combo box at the given id. Id's are assigned with add() +@function iguicombobox:remove() +@tparam number id The id number of the item to remove +*/ +//{combobox}.remove(self,id) int removeitem(lua_State *L){ int idx = lua_tonumber(L,-1);//self,id lua_pop(L,1);//self @@ -105,9 +122,9 @@ static const luaL_reg iguicombobox_f[] = { }; static const luaL_reg iguicombobox_m[] = { - {"addItem", additem}, - {"getSelected", getselected}, - {"removeItem", removeitem}, + {"add", additem}, + {"get", getselected}, + {"remove", removeitem}, {0,0}, }; -- cgit v1.2.3-70-g09d2