Merge pull request #543 from MihailRis/fix-validator-in-textbox

fix: validator not called after backspace
This commit is contained in:
MihailRis 2025-07-13 12:31:25 +03:00 committed by GitHub
commit aca9b49c77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -830,7 +830,12 @@ void TextBox::performEditingKeyboardEvents(Keycode key) {
bool shiftPressed = gui.getInput().pressed(Keycode::LEFT_SHIFT);
bool breakSelection = getSelectionLength() != 0 && !shiftPressed;
if (key == Keycode::BACKSPACE) {
if (!eraseSelected() && caret > 0 && input.length() > 0) {
bool erased = eraseSelected();
if (erased) {
if (validate()) {
onInput();
}
} else if (caret > 0 && input.length() > 0) {
if (caret > input.length()) {
caret = input.length();
}