AvalonStudio.TextEditor.TextEditor.OnPointerPressed C# (CSharp) Method

OnPointerPressed() protected method

protected OnPointerPressed ( PointerPressedEventArgs e ) : void
e PointerPressedEventArgs
return void
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            if (e.Source.InteractiveParent.InteractiveParent == TextView)
            {
                var point = e.GetPosition(TextView.TextSurface);

                var index = TextView.GetOffsetFromPoint(point);

                if (index != -1)
                {
                    CaretIndex = index;

                    var text = TextDocument;

                    switch (e.ClickCount)
                    {
                        case 1:
                            SelectionStart = SelectionEnd = index;
                            break;
                        case 2:
                            SelectionStart = TextUtilities.GetNextCaretPosition(TextDocument, index, TextUtilities.LogicalDirection.Backward,
                                TextUtilities.CaretPositioningMode.WordStart);

                            SelectionEnd = TextUtilities.GetNextCaretPosition(TextDocument, index, TextUtilities.LogicalDirection.Forward,
                                TextUtilities.CaretPositioningMode.WordBorder);
                            break;
                        case 3:
                            SelectionStart = 0;
                            SelectionEnd = text.TextLength;
                            break;
                    }

                    e.Device.Capture(TextView);
                    e.Handled = true;

                    InvalidateVisual();

                    if (CaretChangedByPointerClick != null)
                    {
                        CaretChangedByPointerClick(this, e);
                    }
                }
                else if (TextDocument?.TextLength == 0)
                {
                    SelectionStart = SelectionEnd = CaretIndex = 0;

                    e.Device.Capture(TextView);
                    e.Handled = true;

                    InvalidateVisual();
                }

                SetHighestColumn();
            }
        }