Ejemplo n.º 1
0
 protected override void OnKeyDown(KeyRoutedEventArgs e)
 {
     if ((SelectionHelper.CheckAltKeyPressed() && e.Key == Key.Down) || (SelectionHelper.CheckAltKeyPressed() && e.Key == Key.Up))
     {
         if (!this.ColumnBase.IsEditing)
         {
             this.ColumnBase.Renderer.DataGrid.SelectionController.CurrentCellManager.BeginEdit();
         }
         this.OpenFilterOptionPopup();
         e.Handled = true;
     }
     base.OnKeyDown(e);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Let Renderer decide whether the parent grid should be allowed to handle keys and prevent
        /// the key event from being handled by the visual UIElement for this renderer. If this method
        /// returns true the parent grid will handle arrow keys and set the Handled flag in the event
        /// data. Keys that the grid does not handle will be ignored and be routed to the UIElement
        /// for this renderer.
        /// </summary>
        /// <param name="e">A <see cref="KeyEventArgs" /> object.</param>
        /// <returns>
        /// True if the parent grid should be allowed to handle keys; false otherwise.
        /// </returns>
        protected override bool ShouldGridTryToHandleKeyDown(KeyEventArgs e)
        {
            if (!HasCurrentCellState || !IsInEditing)
            {
                return(true);
            }
#if WPF
            var     combobox     = (CurrentCellRendererElement as ComboBox);
            TextBox comboTextBox = (TextBox)GridUtil.FindDescendantChildByType(combobox, typeof(TextBox));
#endif
#if WPF
            if ((SelectionHelper.CheckAltKeyPressed() && e.SystemKey == Key.Down) || ((SelectionHelper.CheckAltKeyPressed() && e.SystemKey == Key.Up) || e.Key == Key.F4))
#else
            if ((SelectionHelper.CheckAltKeyPressed() && e.Key == Key.Down) || ((SelectionHelper.CheckAltKeyPressed() && e.Key == Key.Up) || e.Key == Key.F4))
#endif
            {
                var comboBox = ((ComboBox)CurrentCellRendererElement);
                comboBox.IsDropDownOpen = !comboBox.IsDropDownOpen;
#if UWP
                comboBox.Focus(FocusState.Programmatic);
#endif
                return(false);
            }

            switch (e.Key)
            {
            case Key.End:
            case Key.Home:
            case Key.Enter:
            case Key.Escape:
                return(!((ComboBox)CurrentCellRendererElement).IsDropDownOpen);

            case Key.Down:
            case Key.Up:
#if UWP
                return(!((ComboBox)CurrentCellRendererElement).IsDropDownOpen);
#endif
#if WPF
                // WPF-25803 - Up/Down Needs to be handle by UiElement itself to change the selection whether drop down open or not/ IsEditable set or not set.
                return(false);

            case Key.Right:
                return(((ComboBox)CurrentCellRendererElement).IsEditable ? (comboTextBox.SelectionStart >= comboTextBox.Text.Length && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed()) : true);

            case Key.Left:
                return(((ComboBox)CurrentCellRendererElement).IsEditable ? (comboTextBox.SelectionStart == comboTextBox.SelectionLength && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed()) : true);
#endif
            }
            return(base.ShouldGridTryToHandleKeyDown(e));
        }