mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 05:42:32 +00:00
[lua] Add possibility to modify a widget label and focus it
This commit is contained in:
parent
8fe01b43f6
commit
bb8d0e7a6a
@ -117,6 +117,12 @@ struct Dialog {
|
|||||||
it->second->setVisible(visible);
|
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,
|
template<typename...Args,
|
||||||
@ -755,6 +761,22 @@ int Dialog_modify(lua_State* L)
|
|||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
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) {
|
if (relayout) {
|
||||||
dlg->window.layout();
|
dlg->window.layout();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user