[lua] Add possibility to modify a widget label and focus it

This commit is contained in:
David Capello 2020-04-07 11:13:30 -03:00
parent 8fe01b43f6
commit bb8d0e7a6a

View File

@ -117,6 +117,12 @@ struct Dialog {
it->second->setVisible(visible);
}
void setLabelText(const char* id, const char* text) {
auto it = labelWidgets.find(id);
if (it != labelWidgets.end())
it->second->setText(text);
}
};
template<typename...Args,
@ -755,6 +761,22 @@ int Dialog_modify(lua_State* L)
}
lua_pop(L, 1);
type = lua_getfield(L, 2, "label");
if (const char* s = lua_tostring(L, -1)) {
dlg->setLabelText(id, s);
relayout = true;
}
lua_pop(L, 1);
type = lua_getfield(L, 2, "focus");
if (type != LUA_TNIL && lua_toboolean(L, -1)) {
widget->requestFocus();
relayout = true;
}
lua_pop(L, 1);
// TODO slider value? combobox option(s)? color? colors (shade)?)
if (relayout) {
dlg->window.layout();