File tree 1 file changed +11
-1
lines changed
Ports/iOSPort/nativeSources
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -7610,7 +7610,17 @@ void com_codename1_impl_ios_IOSNative_updateNativeEditorText___java_lang_String(
7610
7610
NSString* nsText = toNSString(CN1_THREAD_GET_STATE_PASS_ARG text);
7611
7611
NSString* currText = ((UITextView*)editingComponent).text;
7612
7612
if (![nsText isEqualToString:currText]) {
7613
- ((UITextView*)editingComponent).text = nsText;
7613
+ UITextView *textView = (UITextView *)editingComponent;
7614
+
7615
+ // Save current cursor position
7616
+ NSRange selectedRange = textView.selectedRange;
7617
+
7618
+ // Update the text
7619
+ textView.text = nsText;
7620
+
7621
+ // Restore the cursor position
7622
+ NSUInteger newPosition = MIN(selectedRange.location, textView.text.length);
7623
+ textView.selectedRange = NSMakeRange(newPosition, 0);
7614
7624
}
7615
7625
}
7616
7626
POOL_END();
You can’t perform that action at this time.
0 commit comments