Skip to content

Commit 92f188e

Browse files
committed
Update input text when value is changed externally
1 parent 0b3b690 commit 92f188e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/gui/controllers/Input.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ class Input : public ui::Controller {
2323
Property<String> allowRegex{this, "allow", ""};
2424
Property<String> text{this, "text", ""};
2525
Property<String> spanId{this, "span", "value"};
26+
Property<String> value{this, "value", "", &Input::changeValue};
2627
ui::Node* span = nullptr;
2728

28-
Property<String> state{this, "state", "enabled", &Input::changeState};
29-
void changeState() {
29+
void changeValue() {
30+
node()->set("text", *value);
3031
}
3132

3233
void attach() override {
@@ -136,7 +137,7 @@ class Input : public ui::Controller {
136137
offset += insert.size();
137138
}
138139
node()->set("text", Font::toString(entities, false));
139-
node()->set("value", Font::toString(entities, true));
140+
node()->set("value", *value = Font::toString(entities, true));
140141
}
141142

142143
void eventHandler(const ui::TextEvent& event) {
@@ -187,7 +188,7 @@ class Input : public ui::Controller {
187188
}
188189
if (changed) {
189190
node()->set("text", Font::toString(entities, false));
190-
node()->set("value", Font::toString(entities, true));
191+
node()->set("value", *value = Font::toString(entities, true));
191192
node()->processEvent(ui::Changed{node()});
192193
}
193194
} else if (keyName == "RIGHT") {

0 commit comments

Comments
 (0)