textbox editable property fix
This commit is contained in:
@@ -130,7 +130,6 @@ void TextBox::drawBackground(const DrawContext* pctx, Assets*) {
|
|||||||
/// @brief Insert text at the caret. Also selected text will be erased
|
/// @brief Insert text at the caret. Also selected text will be erased
|
||||||
/// @param text Inserting text
|
/// @param text Inserting text
|
||||||
void TextBox::paste(const std::wstring& text) {
|
void TextBox::paste(const std::wstring& text) {
|
||||||
|
|
||||||
eraseSelected();
|
eraseSelected();
|
||||||
if (caret >= input.length()) {
|
if (caret >= input.length()) {
|
||||||
input += text;
|
input += text;
|
||||||
@@ -203,7 +202,9 @@ void TextBox::setTextOffset(uint x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::typed(unsigned int codepoint) {
|
void TextBox::typed(unsigned int codepoint) {
|
||||||
paste(std::wstring({(wchar_t)codepoint}));
|
if (editable) {
|
||||||
|
paste(std::wstring({(wchar_t)codepoint}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextBox::validate() {
|
bool TextBox::validate() {
|
||||||
|
|||||||
@@ -204,6 +204,13 @@ static int p_get_text(UINode* node) {
|
|||||||
return 0;
|
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) {
|
static int p_get_add(UINode* node) {
|
||||||
if (dynamic_cast<Container*>(node)) {
|
if (dynamic_cast<Container*>(node)) {
|
||||||
return state->pushcfunction(l_container_add);
|
return state->pushcfunction(l_container_add);
|
||||||
@@ -268,6 +275,7 @@ static int l_gui_getattr(lua_State* L) {
|
|||||||
{"placeholder", p_get_placeholder},
|
{"placeholder", p_get_placeholder},
|
||||||
{"valid", p_is_valid},
|
{"valid", p_is_valid},
|
||||||
{"text", p_get_text},
|
{"text", p_get_text},
|
||||||
|
{"editable", p_get_editable},
|
||||||
{"value", p_get_value},
|
{"value", p_get_value},
|
||||||
{"min", p_get_min},
|
{"min", p_get_min},
|
||||||
{"max", p_get_max},
|
{"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)));
|
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) {
|
static void p_set_value(UINode* node, int idx) {
|
||||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||||
bar->setValue(state->tonumber(idx));
|
bar->setValue(state->tonumber(idx));
|
||||||
@@ -397,6 +410,7 @@ static int l_gui_setattr(lua_State* L) {
|
|||||||
{"enabled", p_set_enabled},
|
{"enabled", p_set_enabled},
|
||||||
{"placeholder", p_set_placeholder},
|
{"placeholder", p_set_placeholder},
|
||||||
{"text", p_set_text},
|
{"text", p_set_text},
|
||||||
|
{"editable", p_set_editable},
|
||||||
{"value", p_set_value},
|
{"value", p_set_value},
|
||||||
{"min", p_set_min},
|
{"min", p_set_min},
|
||||||
{"max", p_set_max},
|
{"max", p_set_max},
|
||||||
|
|||||||
Reference in New Issue
Block a user