aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui/iguielement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui/iguielement.cpp')
-rw-r--r--src/client/lua_api/gui/iguielement.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp
index 5ba998f..44fb67c 100644
--- a/src/client/lua_api/gui/iguielement.cpp
+++ b/src/client/lua_api/gui/iguielement.cpp
@@ -1,8 +1,6 @@
/*This file defines some things that all igui stuff can do*/
/***
@module gui
-
-
*/
extern "C" {
#include <lua.h>
@@ -86,6 +84,25 @@ int setiguitext(lua_State* L){
return 0;
}
+
+/***
+@function guielement:gettext()
+@treturn string The caption text of the element. For input element like
+editboxes, this returns the text that the edit box contains.
+*/
+//{guieditbox}:gettext() :: "caption_text"
+int getiguitext(lua_State* L){
+ lua_getfield(L, -1, "guielement");//{guieditbox},ud_guielement
+ irr::gui::IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+ const wchar_t *t = el->getText();
+ size_t strlen = wcslen(t);
+ char output[strlen];
+ wcstombs(output,t,strlen);
+ lua_pushstring(L,output);//"str"
+ return 1;
+}
+
/***
Removes a gui element, and any child elements
@function guielement:remove()
@@ -140,3 +157,4 @@ int guigetid(lua_State* L){
lua_pushnumber(L,id);
return 1;
}
+