Example #1
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);

            if (e.Key == Key.Back)
            {
                if ((CaretIndex == 0) && (mLeftParagraph != null) && SelectionLength == 0)
                {
                    mLeftParagraph.Focus();
                    mLeftParagraph.CaretIndex = mLeftParagraph.Text.Length;
                    e.Handled = true;
                }
            }

            if (e.Key == Key.Left)
            {
                if ((CaretIndex == 0) && (mLeftParagraph != null))
                {
                    mLeftParagraph.Focus();
                    mLeftParagraph.CaretIndex = mLeftParagraph.Text.Length;
                    e.Handled = true;
                }
            }

            if (e.Key == Key.Right)
            {
                if ((CaretIndex == Text.Length) && (mRightParagraph != null))
                {
                    mRightParagraph.Focus();
                    mRightParagraph.CaretIndex = 0;
                    e.Handled = true;
                }
            }
        }