예제 #1
0
 /// <summary>
 /// Method which occurs when a keyboard shortcut (or accelerator) is pressed.
 /// Avoids unwanted AutoSuggestBox_SuggestionChosen invocations when pressing Up and Down keys.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void AutoSuggestBox_ProcessKeyboardAccelerators(UIElement sender, ProcessKeyboardAcceleratorEventArgs args)
 {
     if (args.Key == VirtualKey.Down || args.Key == VirtualKey.Up)
     {
         args.Handled = true;
     }
 }
예제 #2
0
 protected override void OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs args)
 {
     if (args.Key == VirtualKey.Space)
     {
         args.Handled = true;
     }
     base.OnProcessKeyboardAccelerators(args);
 }
예제 #3
0
        private async void RichEditBox_ProcessKeyboardAccelerators(UIElement sender, ProcessKeyboardAcceleratorEventArgs args)
        {
            var itemsList = _suggestionsList.Items;

            if (!_suggestionPopup.IsOpen || itemsList == null || itemsList.Count == 0)
            {
                return;
            }

            var key = args.Key;

            switch (key)
            {
            case VirtualKey.Up when itemsList.Count == 1:
            case VirtualKey.Down when itemsList.Count == 1:
                args.Handled = true;
                UpdateSuggestionsListSelectedItem(1);
                break;

            case VirtualKey.Up:
                args.Handled      = true;
                _suggestionChoice = _suggestionChoice <= 0 ? itemsList.Count : _suggestionChoice - 1;
                UpdateSuggestionsListSelectedItem(this._suggestionChoice);
                break;

            case VirtualKey.Down:
                args.Handled      = true;
                _suggestionChoice = _suggestionChoice >= itemsList.Count ? 0 : _suggestionChoice + 1;
                UpdateSuggestionsListSelectedItem(this._suggestionChoice);
                break;

            case VirtualKey.Enter when _suggestionsList.SelectedItem != null:
                args.Handled = true;
                await CommitSuggestionAsync(_suggestionsList.SelectedItem);

                break;

            case VirtualKey.Escape:
                args.Handled = true;
                ShowSuggestionsPopup(false);
                break;
            }
        }
예제 #4
0
 protected override void OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs args)
 {
     base.OnProcessKeyboardAccelerators(args);
 }
예제 #5
0
 void IProcessKeyboardAcceleratorEventArgsResolver.Handled(ProcessKeyboardAcceleratorEventArgs e, bool handled) => e.Handled = handled;
예제 #6
0
 bool IProcessKeyboardAcceleratorEventArgsResolver.Handled(ProcessKeyboardAcceleratorEventArgs e) => e.Handled;
예제 #7
0
 VirtualKeyModifiers IProcessKeyboardAcceleratorEventArgsResolver.Modifiers(ProcessKeyboardAcceleratorEventArgs e) => e.Modifiers;
예제 #8
0
 VirtualKey IProcessKeyboardAcceleratorEventArgsResolver.Key(ProcessKeyboardAcceleratorEventArgs e) => e.Key;
예제 #9
0
 /// <summary>
 /// Sets a value that marks the event as handled.
 /// </summary>
 /// <param name="e">The requested <see cref="ProcessKeyboardAcceleratorEventArgs"/>.</param>
 /// <param name="handled">
 /// <c>true</c> to mark the event handled. <c>false</c> to leave the event unhandled. The default is <c>false</c>.
 /// </param>
 public static void Handled(this ProcessKeyboardAcceleratorEventArgs e, bool handled) => Resolver.Handled(e, handled);
예제 #10
0
 /// <summary>
 /// Gets a value that marks the event as handled.
 /// </summary>
 /// <param name="e">The requested <see cref="ProcessKeyboardAcceleratorEventArgs"/>.</param>
 /// <returns>
 /// <c>true</c> to mark the event handled. <c>false</c> to leave the event unhandled. The default is <c>false</c>.
 /// </returns>
 public static bool Handled(this ProcessKeyboardAcceleratorEventArgs e) => Resolver.Handled(e);
예제 #11
0
 /// <summary>
 /// Gets the virtual key used to modify another keypress for a keyboard shortcut (accelerator).
 /// </summary>
 /// <param name="e">The requested <see cref="ProcessKeyboardAcceleratorEventArgs"/>.</param>
 /// <returns>The virtual key.</returns>
 public static VirtualKeyModifiers Modifiers(this ProcessKeyboardAcceleratorEventArgs e) => Resolver.Modifiers(e);
예제 #12
0
 /// <summary>
 /// Gets the virtual key (used in conjunction with one or more modifier keys) for a keyboard shortcut (accelerator).
 /// </summary>
 /// <param name="e">The requested <see cref="ProcessKeyboardAcceleratorEventArgs"/>.</param>
 /// <returns>The virtual key.</returns>
 public static VirtualKey Key(this ProcessKeyboardAcceleratorEventArgs e) => Resolver.Key(e);