Ejemplo n.º 1
0
        partial void OnFocusStateChangedPartial(FocusState focusState)
        {
            if (_textBoxView == null)
            {
                return;
            }

            if (focusState == FocusState.Unfocused)
            {
                if (_textBoxView.IsFocused)
                {
                    _textBoxView.ClearFocus();
                }
            }
            else
            {
                if (!_textBoxView.IsFocused)
                {
                    using (focusState == FocusState.Programmatic ? PreventKeyboardDisplayIfSet() : null)
                    {
                        _textBoxView.RequestFocus();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        partial void OnFocusStateChangedPartial(FocusState focusState)
        {
            if (_textBoxView == null)
            {
                return;
            }

            if (focusState == FocusState.Unfocused)
            {
                if (_textBoxView.IsFocused)
                {
                    _textBoxView.ClearFocus();
                }
            }
            else
            {
                if (!_textBoxView.IsFocused)
                {
                    using (focusState == FocusState.Programmatic ? PreventKeyboardDisplayIfSet() : null)
                    {
                        _textBoxView.RequestFocus();

                        var selectionStart = this.SelectionStart;

                        if (selectionStart == 0)
                        {
                            int cursorPosition = selectionStart + _textBoxView?.Text?.Length ?? 0;

                            this.Select(cursorPosition, 0);
                        }
                    }
                }
            }
        }