textbox editable property fix

This commit is contained in:
MihailRis
2024-05-12 19:50:07 +03:00
parent 60cfe8595e
commit 1f3cf5ed53
2 changed files with 17 additions and 2 deletions
+14
View File
@@ -204,6 +204,13 @@ static int p_get_text(UINode* node) {
return 0;
}
static int p_get_editable(UINode* node) {
if (auto box = dynamic_cast<TextBox*>(node)) {
return state->pushboolean(box->isEditable());
}
return 0;
}
static int p_get_add(UINode* node) {
if (dynamic_cast<Container*>(node)) {
return state->pushcfunction(l_container_add);
@@ -268,6 +275,7 @@ static int l_gui_getattr(lua_State* L) {
{"placeholder", p_get_placeholder},
{"valid", p_is_valid},
{"text", p_get_text},
{"editable", p_get_editable},
{"value", p_get_value},
{"min", p_get_min},
{"max", p_get_max},
@@ -325,6 +333,11 @@ static void p_set_text(UINode* node, int idx) {
box->setText(util::str2wstr_utf8(state->tostring(idx)));
}
}
static void p_set_editable(UINode* node, int idx) {
if (auto box = dynamic_cast<TextBox*>(node)) {
box->setEditable(state->toboolean(idx));
}
}
static void p_set_value(UINode* node, int idx) {
if (auto bar = dynamic_cast<TrackBar*>(node)) {
bar->setValue(state->tonumber(idx));
@@ -397,6 +410,7 @@ static int l_gui_setattr(lua_State* L) {
{"enabled", p_set_enabled},
{"placeholder", p_set_placeholder},
{"text", p_set_text},
{"editable", p_set_editable},
{"value", p_set_value},
{"min", p_set_min},
{"max", p_set_max},