1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

UIViewComponentPeer: Maintain TextEditor cursor position during deleteBackward

This commit is contained in:
reuk 2022-10-24 12:48:47 +01:00
parent df45aaeb7b
commit c666381ef9
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -919,7 +919,10 @@ MultiTouchMapper<UITouch*> UIViewComponentPeer::currentTouches;
const auto rangeToDelete = range.isEmpty() ? range.withStartAndLength (jmax (range.getStart() - 1, 0),
range.getStart() != 0 ? 1 : 0)
: range;
const auto start = rangeToDelete.getStart();
// This ensures that the cursor is at the beginning, rather than the end, of the selection
target->setHighlightedRegion ({ start, start });
target->setHighlightedRegion (rangeToDelete);
target->insertTextAtCaret ("");
}