MessagePreviewResult IKeyboardListener.OnPreviewKeyDown( Control target, KeyEventArgs e) { if (!this.enabled || this.IsModifierKey(e.KeyCode)) { return(MessagePreviewResult.NotProcessed); } this.currentKeys.Add(e.KeyCode); Keys modifiers = e.Modifiers; Keys[] array = this.currentKeys.ToArray(); bool flag = false; foreach (IShortcutProvider shortcutProvider in this.shortcutProviders) { foreach (RadShortcut shortcut in shortcutProvider.Shortcuts) { if (shortcut.IsShortcutCombination(modifiers, array)) { this.currentKeys.Clear(); ShortcutEventArgs e1 = new ShortcutEventArgs(target, shortcut); shortcutProvider.OnShortcut(e1); if (e1.Handled) { return(MessagePreviewResult.ProcessedNoDispatch); } } else if (!flag && shortcut.IsPartialShortcutCombination(modifiers, array)) { PartialShortcutEventArgs e1 = new PartialShortcutEventArgs(target, shortcut, array); shortcutProvider.OnPartialShortcut(e1); if (e1.Handled) { flag = true; } } } } if (flag) { return(MessagePreviewResult.ProcessedNoDispatch); } this.currentKeys.Clear(); return(MessagePreviewResult.NotProcessed); }
MessagePreviewResult IKeyboardListener.OnPreviewKeyDown(Control target, KeyEventArgs e) { if (!this.enabled) { return(MessagePreviewResult.NotProcessed); } if (this.IsModifierKey(e.KeyCode)) { return(MessagePreviewResult.NotProcessed); } this.currentKeys.Add(e.KeyCode); Keys modifiers = e.Modifiers; Keys[] mappings = this.currentKeys.ToArray(); bool isPartialShortcut = false; //check for shortcut combination first foreach (IShortcutProvider provider in this.shortcutProviders) { foreach (RadShortcut shortcut in provider.Shortcuts) { if (shortcut.IsShortcutCombination(modifiers, mappings)) { this.currentKeys.Clear(); ShortcutEventArgs args = new ShortcutEventArgs(target, shortcut); provider.OnShortcut(args); if (args.Handled) { return(MessagePreviewResult.ProcessedNoDispatch); } //See ticket ID: 316158 //By returning NotProcessed we interrupt the rerouting of the //keyboard message to the other shortcutproviders which might //want to process the shortcut. //return MessagePreviewResult.NotProcessed; } else if (!isPartialShortcut && shortcut.IsPartialShortcutCombination(modifiers, mappings)) { PartialShortcutEventArgs args = new PartialShortcutEventArgs(target, shortcut, mappings); provider.OnPartialShortcut(args); if (args.Handled) { isPartialShortcut = true; } } } } if (isPartialShortcut) { return(MessagePreviewResult.ProcessedNoDispatch); } //the key is not processed, clear all currently collected keys this.currentKeys.Clear(); return(MessagePreviewResult.NotProcessed); }