// Token: 0x06003888 RID: 14472 RVA: 0x000FDA94 File Offset: 0x000FBC94
        private static void UpdateCursor(TextEditor This, Point mouseMovePoint)
        {
            Invariant.Assert(This.TextView != null && This.TextView.IsValid);
            Cursor cursor = Cursors.IBeam;

            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(This.TextView, mouseMovePoint))
            {
                cursor = Cursors.SizeWE;
            }
            else if (This.Selection != null && !This.UiScope.IsMouseCaptured)
            {
                if (This.Selection.IsEmpty)
                {
                    UIElement uielementWhenMouseOver = TextEditorMouse.GetUIElementWhenMouseOver(This, mouseMovePoint);
                    if (uielementWhenMouseOver != null && uielementWhenMouseOver.IsEnabled)
                    {
                        cursor = Cursors.Arrow;
                    }
                }
                else if (This.UiScope.IsFocused && This.Selection.Contains(mouseMovePoint))
                {
                    cursor = Cursors.Arrow;
                }
            }
            if (cursor != This._cursor)
            {
                This._cursor = cursor;
                Mouse.UpdateCursor();
            }
        }
Ejemplo n.º 2
0
        // Check the cursor position against the text selection and see if we need to
        // change which cursor is displayed.  If the cursor is over the selection, show
        // the normal cursor.  Otherwise, show the EditCursors.
        private static void UpdateCursor(TextEditor This, Point mouseMovePoint)
        {
            Invariant.Assert(This.TextView != null && This.TextView.IsValid);

            // Default cursor is editing IBeam
            Cursor cursor = Cursors.IBeam;

            // Check special conditions to setup special cursor shape
            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(This.TextView, mouseMovePoint))
            {
                // Mmouse is over a tablecell border. Cursor must indicate potential column resize
                cursor = Cursors.SizeWE;
            }
            else
            {
                // Check if this position belongs to selected area or is over an embedded UIElement
                if (This.Selection != null && !This.UiScope.IsMouseCaptured)
                {
                    if (This.Selection.IsEmpty)
                    {
                        UIElement uiElement = GetUIElementWhenMouseOver(This, mouseMovePoint);
                        if (uiElement != null && uiElement.IsEnabled)
                        {
                            // Mouse is over an embedded UIElement which is enabled (UiScope may or may not have focus)
                            cursor = Cursors.Arrow;
                        }
                    }
                    else if (This.UiScope.IsFocused && This.Selection.Contains(mouseMovePoint))
                    {
                        // The mouse is over a non-empty selection and we're not dragging
                        cursor = Cursors.Arrow;
                    }
                }
            }

            if (cursor != This._cursor)
            {
                This._cursor = cursor;
                Mouse.UpdateCursor();
            }
        }
Ejemplo n.º 3
0
        // MouseDownEvent handler - used both for Left and Right mouse buttons
        internal static void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextEditor This = TextEditor._GetTextEditor(sender);

            if (This == null)
            {
                return;
            }

            // If UiScope has a ToolTip and it is open, any keyboard/mouse activity should close the tooltip.
            This.CloseToolTip();

            // Ignore the event if the editor has been detached from its scope
            if (!This._IsEnabled)
            {
                return;
            }

            // Ignore the event if the attached scope is not focusable content.
            if (!This.UiScope.Focusable)
            {
                return;
            }

            // MITIGATION: NESTED_MESSAGE_PUMPS_INTERFERE_WITH_INPUT
            // This is a very specific fix for a case where someone displayed a dialog
            // box in response to mouse down.  In general, this entire routine needs
            // to be written to handle that fact that any state can change whenever
            // you call out.  See ButtonBase.OnMouseLeftButtonDown for an example.
            if (e.ButtonState == MouseButtonState.Released)
            {
                return;
            }

            e.Handled = true;

            // Start with moving the focus into this control.
            MoveFocusToUiScope(This);
            if (This.UiScope != Keyboard.FocusedElement)
            {
                return;
            }

            // If this is a right-click, we're done after setting
            // the focus.  Caret is position is only updated when a
            // context menu opens.
            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }

            if (This.TextView == null)
            {
                return;
            }

            // Finalize any active IME compositions.
            // We have to do this async because it will potentially
            // invalidate layout.
            This.CompleteComposition();

            if (!This.TextView.IsValid)
            {
                //


                This.TextView.RenderScope.UpdateLayout();
                if (This.TextView == null || !This.TextView.IsValid)
                {
                    return;
                }
            }

            if (!IsPointWithinInteractiveArea(This, e.GetPosition(This.UiScope)))
            {
                // Mouse down happened over padding area or chrome instead of RenderScope; just set focus
                return;
            }

            // Scale back any background layout in progress.
            This.TextView.ThrottleBackgroundTasksForUserInput();

            // Get the mouse down position.
            Point mouseDownPoint = e.GetPosition(This.TextView.RenderScope);

            // Check if we're at a position where we need to begin a resize operation for table column
            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(This.TextView, mouseDownPoint))
            {
                // Set up resize information, and create adorner
                This._tableColResizeInfo = TextRangeEditTables.StartColumnResize(This.TextView, mouseDownPoint);
                Invariant.Assert(This._tableColResizeInfo != null);

                This._mouseCapturingInProgress = true;
                try
                {
                    This.UiScope.CaptureMouse();
                }
                finally
                {
                    This._mouseCapturingInProgress = false;
                }
            }
            else
            {
                This.Selection.BeginChange();
                try
                {
                    SetCaretPositionOnMouseEvent(This, mouseDownPoint, e.ChangedButton, e.ClickCount);

                    This._mouseCapturingInProgress = true;
                    This.UiScope.CaptureMouse();
                }
                finally
                {
                    This._mouseCapturingInProgress = false;
                    This.Selection.EndChange();
                }
            }
        }
        // Token: 0x0600387F RID: 14463 RVA: 0x000FD304 File Offset: 0x000FB504
        internal static void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                return;
            }
            textEditor.CloseToolTip();
            if (!textEditor._IsEnabled)
            {
                return;
            }
            if (!textEditor.UiScope.Focusable)
            {
                return;
            }
            if (e.ButtonState == MouseButtonState.Released)
            {
                return;
            }
            e.Handled = true;
            TextEditorMouse.MoveFocusToUiScope(textEditor);
            if (textEditor.UiScope != Keyboard.FocusedElement)
            {
                return;
            }
            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }
            if (textEditor.TextView == null)
            {
                return;
            }
            textEditor.CompleteComposition();
            if (!textEditor.TextView.IsValid)
            {
                textEditor.TextView.RenderScope.UpdateLayout();
                if (textEditor.TextView == null || !textEditor.TextView.IsValid)
                {
                    return;
                }
            }
            if (!TextEditorMouse.IsPointWithinInteractiveArea(textEditor, e.GetPosition(textEditor.UiScope)))
            {
                return;
            }
            textEditor.TextView.ThrottleBackgroundTasksForUserInput();
            Point position = e.GetPosition(textEditor.TextView.RenderScope);

            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(textEditor.TextView, position))
            {
                textEditor._tableColResizeInfo = TextRangeEditTables.StartColumnResize(textEditor.TextView, position);
                Invariant.Assert(textEditor._tableColResizeInfo != null);
                textEditor._mouseCapturingInProgress = true;
                try
                {
                    textEditor.UiScope.CaptureMouse();
                    return;
                }
                finally
                {
                    textEditor._mouseCapturingInProgress = false;
                }
            }
            textEditor.Selection.BeginChange();
            try
            {
                TextEditorMouse.SetCaretPositionOnMouseEvent(textEditor, position, e.ChangedButton, e.ClickCount);
                textEditor._mouseCapturingInProgress = true;
                textEditor.UiScope.CaptureMouse();
            }
            finally
            {
                textEditor._mouseCapturingInProgress = false;
                textEditor.Selection.EndChange();
            }
        }