Example #1
0
        private void KeydownEventHandler(object sender, IControlHtmlEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            LogTo.Debug("Handling key down");
            var ev = e?.EventObj;

            if (ev == null)
            {
                return;
            }

            if (CurrentPopup == null || !CurrentPopup.IsOpen())
            {
                return;
            }

            var info = new HtmlKeyInfo(ev);

            if (info.Key == Keys.None)
            {
                return;
            }

            if (info.Key == Keys.Escape)
            {
                CurrentPopup?.Hide();
                ev.returnValue = false;
            }
            else if ((info.Key == Keys.Up && info.Modifiers == KeyModifiers.None) ||
                     (info.Key == Keys.K && info.Modifiers == KeyModifiers.Ctrl))
            {
                CurrentPopup?.SelectPreviousItem();
                ev.returnValue = false;
            }
            else if ((info.Key == Keys.Down && info.Modifiers == KeyModifiers.None) ||
                     (info.Key == Keys.J && info.Modifiers == KeyModifiers.Ctrl))
            {
                CurrentPopup?.SelectNextItem();
                ev.returnValue = false;
            }
            else if ((info.Key == Keys.Right && info.Modifiers == KeyModifiers.None) ||
                     info.Key == Keys.Tab)
            {
                CurrentPopup?.InsertSelectedItem();
                ev.returnValue = false;
            }
        }
Example #2
0
        private void OnTabPressed()
        {
            if (CurrentPopup == null || !CurrentPopup.IsOpen())
            {
                if (!SelectPlaceholder())
                {
                    Svc.SM.UI.ElementWdw.SendKeys(new HotKey(Key.Tab));
                }
            }
            else if (CurrentPopup.IsOpen() && CurrentPopup.GetSelectedItem() == null)
            {
                if (!SelectPlaceholder())
                {
                    Svc.SM.UI.ElementWdw.SendKeys(new HotKey(Key.Tab));
                    return;
                }

                CurrentPopup.Hide();
            }
            else
            {
                CurrentPopup.InsertSelectedItem();
            }
        }