// 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(); } }