Exemple #1
0
        internal static int GetCursorPosition(this IUITextInput platformView, int cursorOffset = 0)
        {
            var zeroPosition          = platformView.GetPosition(platformView.BeginningOfDocument, 0);
            var currentCursorPosition = platformView.SelectedTextRange?.Start ?? zeroPosition;
            var newCursorPosition     = cursorOffset + (int)platformView.GetOffsetFromPosition(platformView.BeginningOfDocument, currentCursorPosition);

            return(Math.Max(0, newCursorPosition));
        }
Exemple #2
0
        internal static int GetSelectedTextLength(this IUITextInput platformView)
        {
            var selectedTextRange = platformView.SelectedTextRange;

            if (selectedTextRange == null)
            {
                return(0);
            }

            return((int)platformView.GetOffsetFromPosition(selectedTextRange.Start, selectedTextRange.End));
        }