mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Implement Input::on_change.
This commit is contained in:
parent
5291f660ca
commit
606e0efdfe
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user