static void UpdateCursorSelection(this UITextView textView, IEditor editor) { if (!editor.IsReadOnly) { UITextPosition start = GetSelectionStart(textView, editor, out int startOffset); UITextPosition end = GetSelectionEnd(textView, editor, start, startOffset); textView.SelectedTextRange = textView.GetTextRange(start, end); } }
private void ReplaceOnCurrentCursorWith(NSRange misspelledWord, string word) { var start = _content.GetPosition(_content.BeginningOfDocument, misspelledWord.Location); var end = _content.GetPosition(start, misspelledWord.Length); var textRange = _content.GetTextRange(start, end); _content.ReplaceText(textRange, word); MarkSpellingForCursorRange(); }
protected override void OnAttached() { if (Element is Editor edit) { editor = edit; } if (Control != null) { if (Control is UITextView view) { editView = view; // If the EditText has by default a text, we set the caret to the end if (editView.Text?.Length > 0) { editView.SelectedTextRange = editView.GetTextRange(editView.EndOfDocument, editView.EndOfDocument); } if (maxLines > 0) { maxHeight = editView.Font.LineHeight * maxLines; editView.Changed += EditView_Changed; } } else if (Control is UITextField field) { editText = field; // If the EditText has by default a text, we set the caret to the end if (editText.Text?.Length > 0) { editText.SelectedTextRange = editText.GetTextRange(editText.EndOfDocument, editText.EndOfDocument); } } if ((editView != null) || (editText != null)) { entryEffect = (MultiPlatformApplication.Effects.EntryEffect)Element.Effects.FirstOrDefault(e => e is MultiPlatformApplication.Effects.EntryEffect); if (MultiPlatformApplication.Effects.EntryEffect.GetNoBorder(Element) == true) { NoBorder(); } RegisterKeyboardObserver(); } } //SetTintColor(); }