Пример #1
0
        internal virtual void OnCellKeyPress(CellKeyPressEventArgs args)
        {
#if DEBUG_LISTVIEW
            Debug.WriteLine(string.Format("ListView received {0} at {1}", "OnCellKeyPress", args.Cell));
#endif

            OnCellKeyPressEvent(args);
        }
Пример #2
0
        protected internal override void OnKeyPressEvent(CellKeyPressEventArgs args)
        {
            if (eventLock)
            {
                return;
            }

            try {
                eventLock = true;

                CellPosition editPos = ParentColumn.ParentListView.EditedCell;
                if (args.Cell == editPos)
                {
                    args.Entry = entry;
                }

                base.OnKeyPressEvent(args);

                if (!IsEditable)
                {
                    return;
                }

                if (parentColumn.ParentListView.ManualEditControl)
                {
                    return;
                }

                switch (args.GdkKey)
                {
                case Key.Return:
                case Key.KP_Enter:
                    if (editPos == args.Cell)
                    {
                        EndCellEdit(ParseObject(entry.Text));
                    }
                    else
                    {
                        BeginCellEdit(args);
                    }
                    break;

                case Key.Escape:
                    if (editPos == args.Cell)
                    {
                        CancelCellEdit();
                    }
                    break;
                }
            } finally {
                eventLock = false;
            }
        }
Пример #3
0
        protected internal virtual void OnKeyPressEvent(CellKeyPressEventArgs args)
        {
#if DEBUG_LISTVIEW
            Debug.WriteLine(string.Format("Cell received {0} at {1}", "OnKeyPressEvent", args.Cell));
#endif
            if (KeyPressEvent != null)
            {
                KeyPressEvent(this, args);
            }

            if (parentColumn != null)
            {
                parentColumn.OnKeyPressEvent(args);
            }
        }
        private bool OnCellKeyPressEvent(CellKeyPressEventArgs args)
        {
            if (eventLock)
            {
                return(true);
            }

            try {
                eventLock = true;
                if (cellsFucusable && args.Cell.IsValid)
                {
                    column_cache [args.Cell.Column].Column.ListCell.OnKeyPressEvent(args);
                }

                if (CellKeyPressEvent != null)
                {
                    CellKeyPressEvent(this, args);
                }

#if DEBUG_LISTVIEW
                Debug.WriteLine(string.Format("ListView received {0}", "OnCellKeyPressEvent"));
#endif

                bool ret;
                // Don't send arrow keys to the parent because the focus gets lost
                switch (args.GdkKey)
                {
                case Gdk.Key.Up:
                case Gdk.Key.KP_Up:
                case Gdk.Key.Down:
                case Gdk.Key.KP_Down:
                case Gdk.Key.Left:
                case Gdk.Key.Right:
                    ret = true;
                    break;

                default:
                    ret = base.OnKeyPressEvent(args.EventKey);
                    break;
                }

                switch (args.GdkKey)
                {
                case Gdk.Key.Up:
                case Gdk.Key.KP_Up:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, -1));
                    }
                    break;

                case Gdk.Key.Down:
                case Gdk.Key.KP_Down:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, 1));
                    }
                    break;

                case Gdk.Key.Left:
                    if (!manualFucusChange && cellsFucusable)
                    {
                        FocusCell(selection.FocusedCell.Column - 1, selection.FocusedCell.Row);
                        InvalidateList();
                    }
                    break;

                case Gdk.Key.Right:
                    if (!manualFucusChange && cellsFucusable)
                    {
                        FocusCell(selection.FocusedCell.Column + 1, selection.FocusedCell.Row);
                        InvalidateList();
                    }
                    break;

                case Gdk.Key.Page_Up:
                case Gdk.Key.KP_Page_Up:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State,
                                              (int)(-vadjustment.PageIncrement / RowHeight)));
                    }
                    break;

                case Gdk.Key.Page_Down:
                case Gdk.Key.KP_Page_Down:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State,
                                              (int)(vadjustment.PageIncrement / RowHeight)));
                    }
                    break;

                case Gdk.Key.Home:
                case Gdk.Key.KP_Home:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, -10000000));
                    }
                    break;

                case Gdk.Key.End:
                case Gdk.Key.KP_End:
                    if (!manualFucusChange)
                    {
                        return(KeyboardScroll(args.EventKey.State, 10000000));
                    }
                    break;

                case Gdk.Key.Return:
                case Gdk.Key.KP_Enter:
                    ActivateRow();
                    break;

                default:
                    char keyChar = (char)Keyval.ToUnicode((uint)args.GdkKey);

                    if (char.ToLower(keyChar) == 'a' && (args.EventKey.State & KeyShortcuts.ControlModifier) != 0)
                    {
                        if (allowMultipleSelect)
                        {
                            if ((args.EventKey.State & ModifierType.ShiftMask) != 0)
                            {
                                selection.Clear();
                            }
                            else
                            {
                                selection.SelectAll();
                            }
                            QueueDraw();
                        }
                        return(ret);
                    }

                    if (!editedCell.IsValid)
                    {
                        if (keyChar != '\0')
                        {
                            if (char.ToLower(keyChar) == 'v' && (args.EventKey.State & KeyShortcuts.ControlModifier) != 0)
                            {
                                Clipboard clip = Clipboard.Get(Atom.Intern("CLIPBOARD", false));
                                SetAutoFilter(autoFilterValue + clip.WaitForText(), true);
                            }
                            else
                            {
                                SetAutoFilter(autoFilterValue + keyChar, true);
                            }
                        }
                        else if (args.GdkKey == Gdk.Key.BackSpace)
                        {
                            SetAutoFilter(autoFilterValue.Substring(0, Math.Max(0, autoFilterValue.Length - 1)), true);
                        }
                    }

                    break;
                }

                return(ret);
            } finally {
                eventLock = false;
            }
        }