Implement Input::on_change.

This commit is contained in:
ArthurSonzogni 2020-09-20 11:47:06 +02:00
parent 5291f660ca
commit 606e0efdfe
2 changed files with 5 additions and 2 deletions

View File

@ -20,8 +20,8 @@ class Input : public Component {
std::wstring placeholder;
// State update callback.
std::function<void()> on_change = []() {};
std::function<void()> on_enter = []() {};
std::function<void()> on_change = [] {};
std::function<void()> on_enter = [] {};
// Component implementation.
Element Render() override;

View File

@ -52,6 +52,7 @@ bool Input::OnEvent(Event event) {
return false;
content.erase(cursor_position - 1, 1);
cursor_position--;
on_change();
return true;
}
@ -60,6 +61,7 @@ bool Input::OnEvent(Event event) {
if (cursor_position == int(content.size()))
return false;
content.erase(cursor_position, 1);
on_change();
return true;
}
@ -87,6 +89,7 @@ bool Input::OnEvent(Event event) {
if (event.is_character()) {
content.insert(cursor_position, 1, event.character());
cursor_position++;
on_change();
return true;
}
return false;