mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
lua: add setValue() for menu forwarders
menu1:setSelected{id=<id>,value="text"}
This commit is contained in:
@@ -76,6 +76,7 @@ void CLuaInstMenu::MenuRegister(lua_State *L)
|
||||
{ "setActive", CLuaInstMenu::MenuSetActive },
|
||||
{ "setName", CLuaInstMenu::MenuSetName },
|
||||
{ "setSelected", CLuaInstMenu::MenuSetSelected },
|
||||
{ "setValue", CLuaInstMenu::MenuSetValue },
|
||||
{ "__gc", CLuaInstMenu::MenuDelete },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
@@ -590,3 +591,24 @@ int CLuaInstMenu::MenuSetSelected(lua_State *L)
|
||||
D->m->setSelected(preselected);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CLuaInstMenu::MenuSetValue(lua_State *L)
|
||||
{
|
||||
lua_assert(lua_istable(L, 2));
|
||||
CLuaMenu *D = MenuCheck(L, 1);
|
||||
if (!D) return 0;
|
||||
|
||||
lua_Integer id; tableLookup(L, "item", id);
|
||||
std::string value; tableLookup(L, "value", value);
|
||||
|
||||
CMenuItem* item = NULL;
|
||||
for (itemmap_iterator_t it = D->itemmap.begin(); it != D->itemmap.end(); ++it) {
|
||||
if (it->first == id) {
|
||||
item = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item)
|
||||
static_cast<CMenuForwarder*>(item)->setOption(value);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -128,6 +128,7 @@ class CLuaInstMenu
|
||||
static int MenuSetName(lua_State *L);
|
||||
static int MenuDelete(lua_State *L);
|
||||
static int MenuSetSelected(lua_State *L);
|
||||
static int MenuSetValue(lua_State *L);
|
||||
};
|
||||
|
||||
#endif //_LUAMENUE_H
|
||||
|
Reference in New Issue
Block a user