textbox autoresize

This commit is contained in:
MihailRis
2024-05-14 05:05:13 +03:00
parent ea2b77b323
commit 8bf65eef1a
6 changed files with 164 additions and 81 deletions
+16
View File
@@ -70,6 +70,14 @@ static int l_menu_reset(lua_State* L) {
return 0;
}
static int l_textbox_paste(lua_State* L) {
auto node = getDocumentNode(L);
auto box = dynamic_cast<TextBox*>(node.node.get());
auto text = lua_tostring(L, 2);
box->paste(util::str2wstr_utf8(text));
return 0;
}
static int l_container_add(lua_State* L) {
auto docnode = getDocumentNode(L);
auto node = dynamic_cast<Container*>(docnode.node.get());
@@ -121,6 +129,13 @@ static int p_get_back(UINode* node) {
return 0;
}
static int p_get_paste(UINode* node) {
if (dynamic_cast<TextBox*>(node)) {
return state->pushcfunction(l_textbox_paste);
}
return 0;
}
static int p_get_page(UINode* node) {
if (auto menu = dynamic_cast<Menu*>(node)) {
return state->pushstring(menu->getCurrent().name);
@@ -289,6 +304,7 @@ static int l_gui_getattr(lua_State* L) {
{"page", p_get_page},
{"back", p_get_back},
{"reset", p_get_reset},
{"paste", p_get_paste},
{"inventory", p_get_inventory},
{"focused", p_get_focused},
};