// Token: 0x0600470D RID: 18189 RVA: 0x00142340 File Offset: 0x00140540
        private void OnAnyMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            bool isKeyboardFocusWithin = base.IsKeyboardFocusWithin;
            bool flag = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

            if (isKeyboardFocusWithin && !flag && !e.Handled && this.IsSelected)
            {
                DataGrid dataGridOwner = this.DataGridOwner;
                if (dataGridOwner != null)
                {
                    dataGridOwner.HandleSelectionForCellInput(this, false, true, false);
                    if (!this.IsEditing && !this.IsReadOnly)
                    {
                        dataGridOwner.BeginEdit(e);
                        e.Handled = true;
                        return;
                    }
                }
            }
            else if (!isKeyboardFocusWithin || !this.IsSelected || flag)
            {
                if (!isKeyboardFocusWithin)
                {
                    base.Focus();
                }
                DataGrid dataGridOwner2 = this.DataGridOwner;
                if (dataGridOwner2 != null)
                {
                    dataGridOwner2.HandleSelectionForCellInput(this, Mouse.Captured == null, true, true);
                }
                e.Handled = true;
            }
        }
Example #2
0
        /// <summary>
        ///     The left mouse button was pressed
        /// </summary>
        ///
        private void OnAnyMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            bool focusWithin      = IsKeyboardFocusWithin;
            bool isCtrlKeyPressed = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

            if (focusWithin && !isCtrlKeyPressed && !e.Handled && IsSelected)
            {
                // The cell is focused and there are no other special selection gestures,
                // enter edit mode.
                DataGrid dataGridOwner = DataGridOwner;
                if (dataGridOwner != null)
                {
                    // The cell was clicked, which means that other cells may
                    // need to be de-selected, let the DataGrid handle that.
                    dataGridOwner.HandleSelectionForCellInput(this, /* startDragging = */ false, /* allowsExtendSelect = */ true, /* allowsMinimalSelect = */ false);

                    if (!IsEditing && !IsReadOnly)
                    {
                        // Enter edit mode
                        dataGridOwner.BeginEdit(e);
                        e.Handled = true;
                    }

                    // Please note that unselecting rows is not really considered a
                    // handlable operation. Please see Dev11 bug#245510 about
                    // this issue.
                    //e.Handled = true;
                }
            }
            else if (!focusWithin || !IsSelected || isCtrlKeyPressed)
            {
                if (!focusWithin)
                {
                    // The cell should receive focus on click
                    Focus();
                }

                DataGrid dataGridOwner = DataGridOwner;
                if (dataGridOwner != null)
                {
                    // Let the DataGrid process selection
                    dataGridOwner.HandleSelectionForCellInput(this, /* startDragging = */ Mouse.Captured == null, /* allowsExtendSelect = */ true, /* allowsMinimalSelect = */ true);
                }

                e.Handled = true;
            }
#if PUBLIC_ONINPUT
            else
            {
                SendInputToColumn(e);
            }
#endif
        }