Exemplo n.º 1
0
        private bool OnKeyDown(Keys key)
        {
            bool handled = true;

            // down and up change the selection
            if (key == Keys.Up)
            {
                if (fastOLV.SelectedIndex > 0)
                {
                    fastOLV.SelectedIndex--;
                }
                else
                {
                    fastOLV.SelectedIndex = (TotalItems - 1);
                }
                if (fastOLV.SelectedIndex >= 0)
                {
                    fastOLV.EnsureVisible(fastOLV.SelectedIndex);
                }
            }
            else if (key == Keys.Down)
            {
                if (fastOLV.SelectedIndex < (TotalItems - 1))
                {
                    fastOLV.SelectedIndex++;
                }
                else
                {
                    fastOLV.SelectedIndex = 0;
                }
                if (fastOLV.SelectedIndex >= 0)
                {
                    fastOLV.EnsureVisible(fastOLV.SelectedIndex);
                }

                // escape close
            }
            else if (key == Keys.Escape)
            {
                Npp.GrabFocus();

                // enter and tab accept the current selection
            }
            else if (key == Keys.Enter)
            {
                OnActivateItem();
            }
            else if (key == Keys.Tab)
            {
                OnActivateItem();
                GiveFocustoTextBox();

                // else, any other key is unhandled
            }
            else
            {
                handled = false;
            }

            // down and up activate the display of tooltip
            if (key == Keys.Up || key == Keys.Down)
            {
                // TODO
                //InfoToolTip.InfoToolTip.ShowToolTipFromAutocomplete(GetCurrentSuggestion(), new Rectangle(new Point(Location.X, Location.Y), new Size(Width, Height)), _isReversed);
            }
            return(handled);
        }