[lua] Add support to modify tabs buttons via Dialog:modify

This commit is contained in:
Martín Capello 2023-08-29 17:49:02 -03:00 committed by David Capello
parent 6010748f81
commit 815366d385

View File

@ -1304,10 +1304,13 @@ int Dialog_tab(lua_State* L)
std::string text;
std::string id;
bool hasId = false;
if (lua_istable(L, 2)) {
int type = lua_getfield(L, 2, "id");
if (type != LUA_TNIL)
if (type != LUA_TNIL) {
id = lua_tostring(L, -1);
hasId = !id.empty();
}
lua_pop(L, 1);
type = lua_getfield(L, 2, "text");
@ -1317,7 +1320,7 @@ int Dialog_tab(lua_State* L)
lua_pop(L, 1);
// If there was no id set, then use the tab text as the tab id.
if (id.empty()) id = text;
if (!hasId) id = text;
}
if (!dlg->wipTab) {
@ -1332,6 +1335,8 @@ int Dialog_tab(lua_State* L)
auto tabBtn = dlg->wipTab->addTab(tabContent);
dlg->currentGrid = tabContent;
if (hasId) dlg->dataWidgets[id] = tabBtn;
if (lua_istable(L, 2)) {
int type = lua_getfield(L, 2, "onclick");
if (type == LUA_TFUNCTION) {