From bb8d0e7a6afabf9cd6e948d4e7a4fe99a117af23 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 7 Apr 2020 11:13:30 -0300 Subject: [PATCH] [lua] Add possibility to modify a widget label and focus it --- src/app/script/dialog_class.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/script/dialog_class.cpp b/src/app/script/dialog_class.cpp index d94aa5d1a..ecaadf372 100644 --- a/src/app/script/dialog_class.cpp +++ b/src/app/script/dialog_class.cpp @@ -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); + } + }; templatesetLabelText(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();