Browse Source

Fix TextBox sync issues (#14960)

* Sync change text and changed caret index with the TextPresenter when text input is handled

* Do not add length again
pull/14954/head
Benedikt Stebner 2 years ago
committed by GitHub
parent
commit
1249a5fccf
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      src/Avalonia.Controls/TextBox.cs

10
src/Avalonia.Controls/TextBox.cs

@ -1063,7 +1063,15 @@ namespace Avalonia.Controls
_undoRedoHelper.DiscardRedo();
}
SetCurrentValue(CaretIndexProperty, caretIndex + input.Length);
//Make sure updated text is in sync
_presenter?.SetCurrentValue(TextPresenter.TextProperty, text);
caretIndex += input.Length;
//Make sure caret is in sync
_presenter?.MoveCaretToTextPosition(caretIndex);
SetCurrentValue(CaretIndexProperty, caretIndex);
}
}

Loading…
Cancel
Save