File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Ports/iOSPort/nativeSources Expand file tree Collapse file tree 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(
76107610 NSString* nsText = toNSString(CN1_THREAD_GET_STATE_PASS_ARG text);
76117611 NSString* currText = ((UITextView*)editingComponent).text;
76127612 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);
76147624 }
76157625 }
76167626 POOL_END();
You can’t perform that action at this time.
0 commit comments