Beispiel #1
0
        private void ScrollView_KeyRepeated(WidgetInput input, Key key)
        {
            if (history == null || history.Count < 1)
            {
                return;
            }

            if (key == Key.Mouse0)
            {
                scrollView.SetFocus();
                selectedIndex = (resultPane.LocalMousePosition().Y / rowHeight).Floor().Clamp(0, history.Count - 1);
            }
            else if (Cmds.Down.WasIssued())
            {
                selectedIndex++;
                Cmds.Down.Consume();
            }
            else if (Cmds.Up.WasIssued())
            {
                selectedIndex--;
                Cmds.Up.Consume();
            }
            else if (Cmds.Cancel.WasIssued())
            {
                scrollView.RevokeFocus();
                Cmds.Cancel.Consume();
            }
            else if (Cmds.Enter.WasIssued() || key == Key.Mouse0DoubleClick)
            {
                Document.Current.History.DoTransaction(() => NavigateToItem(selectedIndex));
                Cmds.Enter.Consume();
            }
            else
            {
                return;
            }

            selectedIndex = selectedIndex.Clamp(0, history?.Count - 1 ?? 0);
            EnsureRowVisible(selectedIndex);
            Window.Current.Invalidate();
        }
Beispiel #2
0
 void ScrollView_KeyRepeated(WidgetInput input, Key key)
 {
     if (Cmds.All.Contains(key))
     {
         input.ConsumeKey(key);
     }
     if (results.Count == 0)
     {
         return;
     }
     if (key == Key.Mouse0)
     {
         scrollView.SetFocus();
         selectedIndex = (resultPane.Input.LocalMousePosition.Y / rowHeight).Floor().Clamp(0, results.Count - 1);
     }
     else if (key == Cmds.Down)
     {
         selectedIndex++;
     }
     else if (key == Cmds.Up)
     {
         selectedIndex--;
     }
     else if (key == Cmds.Cancel)
     {
         scrollView.RevokeFocus();
     }
     else if (key == Cmds.Enter || key == Key.Mouse0DoubleClick)
     {
         NavigateToItem(selectedIndex);
     }
     else
     {
         return;
     }
     selectedIndex = selectedIndex.Clamp(0, results != null ? results.Count - 1 : 0);
     EnsureRowVisible(selectedIndex);
     Window.Current.Invalidate();
 }