From c666381ef9a2f7f5e4d57fbc9268b7e3abb4415b Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 24 Oct 2022 12:48:47 +0100 Subject: [PATCH] UIViewComponentPeer: Maintain TextEditor cursor position during deleteBackward --- modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index b83c036e7a..aad028dae1 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -919,7 +919,10 @@ MultiTouchMapper 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 (""); }