diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 2375a1375..68a36e80a 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1537,6 +1537,7 @@ void CLuaInstance::ComponentsTextRegister(lua_State *L) { "new", CLuaInstance::ComponentsTextNew }, { "paint", CLuaInstance::ComponentsTextPaint }, { "hide", CLuaInstance::ComponentsTextHide }, + { "setText", CLuaInstance::ComponentsTextSetText }, { "scroll", CLuaInstance::ComponentsTextScroll }, { "__gc", CLuaInstance::ComponentsTextDelete }, { NULL, NULL } @@ -1610,6 +1611,8 @@ int CLuaInstance::ComponentsTextNew(lua_State *L) *udata = new CLuaComponentsText(); (*udata)->ct = new CComponentsText(x, y, dx, dy, text, mode, g_Font[font_text], pw, has_shadow, (fb_pixel_t)color_text, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow); (*udata)->parent = pw; + (*udata)->mode = mode; + (*udata)->font_text = font_text; luaL_getmetatable(L, "ctext"); lua_setmetatable(L, -2); return 1; @@ -1639,8 +1642,28 @@ int CLuaInstance::ComponentsTextHide(lua_State *L) tableLookup(L, "no_restore", tmp); bool no_restore = (tmp == "true" || tmp == "1" || tmp == "yes"); - m->ct->hide(no_restore); + if (m->parent) { + m->ct->setText("", m->mode, g_Font[m->font_text]); + m->ct->paint(); + } else + m->ct->hide(no_restore); + return 0; +} +int CLuaInstance::ComponentsTextSetText(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + CLuaComponentsText *m = ComponentsTextCheck(L, 1); + if (!m) return 0; + + std::string text = ""; + int mode = m->mode; + int font_text = m->font_text; + tableLookup(L, "text", text); + tableLookup(L, "mode", mode); + tableLookup(L, "font_text", font_text); + + m->ct->setText(text, mode, g_Font[font_text]); return 0; } diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 711a2895c..388e2b427 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -139,7 +139,8 @@ class CLuaComponentsText public: CComponentsText *ct; CComponentsForm *parent; - CLuaComponentsText() { ct = NULL; parent = NULL;} + int mode, font_text; + CLuaComponentsText() { ct = NULL; parent = NULL; mode = 0; font_text = 0;} ~CLuaComponentsText() { if (parent == NULL) delete ct; } }; @@ -214,6 +215,7 @@ private: static int ComponentsTextNew(lua_State *L); static int ComponentsTextPaint(lua_State *L); static int ComponentsTextHide(lua_State *L); + static int ComponentsTextSetText(lua_State *L); static int ComponentsTextScroll(lua_State *L); static int ComponentsTextDelete(lua_State *L);