mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Fix Input onchange not called (#776)
This commit is contained in:
parent
0631c3ab3f
commit
e8589dd533
@ -7,6 +7,8 @@ current (development)
|
|||||||
### Component
|
### Component
|
||||||
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
|
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
|
||||||
option. Added by @mingsheng13.
|
option. Added by @mingsheng13.
|
||||||
|
- Bugfix: `Input` `onchange` was not called on backspace or delete key.
|
||||||
|
Fixed by @chrysante in chrysante in PR #776.
|
||||||
|
|
||||||
### Dom
|
### Dom
|
||||||
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
||||||
|
@ -207,10 +207,11 @@ class InputBase : public ComponentBase, public InputOption {
|
|||||||
const size_t end = cursor_position();
|
const size_t end = cursor_position();
|
||||||
content->erase(start, end - start);
|
content->erase(start, end - start);
|
||||||
cursor_position() = start;
|
cursor_position() = start;
|
||||||
|
on_change();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleDelete() {
|
bool DeleteImpl() {
|
||||||
if (cursor_position() == (int)content->size()) {
|
if (cursor_position() == (int)content->size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -220,6 +221,14 @@ class InputBase : public ComponentBase, public InputOption {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HandleDelete() {
|
||||||
|
if (DeleteImpl()) {
|
||||||
|
on_change();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool HandleArrowLeft() {
|
bool HandleArrowLeft() {
|
||||||
if (cursor_position() == 0) {
|
if (cursor_position() == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -345,7 +354,7 @@ class InputBase : public ComponentBase, public InputOption {
|
|||||||
bool HandleCharacter(const std::string& character) {
|
bool HandleCharacter(const std::string& character) {
|
||||||
if (!insert() && cursor_position() < (int)content->size() &&
|
if (!insert() && cursor_position() < (int)content->size() &&
|
||||||
content()[cursor_position()] != '\n') {
|
content()[cursor_position()] != '\n') {
|
||||||
HandleDelete();
|
DeleteImpl();
|
||||||
}
|
}
|
||||||
content->insert(cursor_position(), character);
|
content->insert(cursor_position(), character);
|
||||||
cursor_position() += character.size();
|
cursor_position() += character.size();
|
||||||
|
Loading…
Reference in New Issue
Block a user