Shortcut key conflict

SyntaxEditor for WPF Forum

Posted 2 years ago by SPF - Appeon
Version: 22.1.1
Avatar

Now I want a shortcut key to do my own thing. For example, "Ctrl + -", but the shortcut key is bound to the control itself by default. How can I set it to work with my own behavior?

Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

If you want total control over input bindings, you can override the "SyntaxEditor.ResetInputBindings" method and set the bindings you want. If you never call the base method, none of the default input bindings will be defined.

If you just want to remove a single input binding, you can find that key combination in the input bindings collection and remove it. Note that some commands, like the ZoomOut command, can have multiple input bindings since the "minus" key is also the "subtract" key on the number pad.

You can use the "Edit Actions" QuickStart in the Sample Browser to view the first input binding for each command.

You could use something like the following code to clear the "Ctrl + -" binding:

...

RemoveInputBinding(Key.OemMinus, ModifierKeys.Control);
RemoveInputBinding(Key.Subtract, ModifierKeys.Control);

...

private void RemoveInputBinding(Key key, ModifierKeys modifiers) {
	foreach (InputBinding binding in editor.InputBindings) {
		KeyBinding keyBinding = binding as KeyBinding;
		if (keyBinding != null) {
			if (keyBinding.Key == key && keyBinding.Modifiers == modifiers) {
				editor.InputBindings.Remove(keyBinding);
				break;
			}
		}
	}
}


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.