Last Updated:
06 Mar 2023 15:23
by ADMIN
SyntaxEditor: Registering Ctrl + Enter keybinding to command results in command not executing when pressing Ctrl+Enter
Enter key is improperly handled internally and this results in inability to use the key in combination with other modifier keys for custom commands.
For example this custom code completion command does not fire when pressing Ctrl + Enter:
private void syntaxEditor_Loaded(object sender, RoutedEventArgs e)
{
var completionCommand = this.syntaxEditor.Commands.CodeCompletionCommand;
InputBinding keyBinding = null;
foreach (InputBinding item in this.syntaxEditor.EditorPresenter.Caret.InputBindings)
{
if (item.Command == completionCommand)
{
keyBinding = item;
break;
}
}
// unregister old key binding via Caret InputBindings
this.syntaxEditor.EditorPresenter.Caret.InputBindings.Remove(keyBinding);
// register new command in Syntaxeditor
this.syntaxEditor.KeyBindings.RegisterCommand(completionCommand, Key.Enter, ModifierKeys.Control);
}