How to change Keyboard shortcut mappings

I am trying to switch from a COM code editor to SyntaxEditor and am running into some problems with keyboard shortcuts being different from the old editor. (Which was compatible with an older version of Visual Studio)

In my old tool there was a keyboard mapping object that I could alter in order to change the mappings, or prevent specific ones from firing anything at all.

Does SyntaxEditor have a similar mapping object, or is there an alternative way to handle this?

Two specific problems I have found so far are:

Block Selection - we use Ctrl+LeftMouse vs your Alt+LeftMouse (Alt+ does match VS 2008 but we generally avoid Alt if we can)

Ctrl+MouseWheel which we use for Zoom In/Out. (you seem to ignore the control keys altogether and scroll the view in all cases ... which is not VS compatible.)I used the MouseWheel() event to implement my Zoom feature but since the event is not cancelable it also scrolls the view. I don't see a property to switch off mouse wheel scrolling so how do I prevent that from happening. (Ideally I only want to switch off the Ctrl+Wheel combination but if I have to switch off all Mouse wheel handling I guess I can implement View scrolling myself.)

In general, how do I modify/add/remove your built-in shortcuts?

Thanks

Comments (13)

The virtual SyntaxEditor.ResetCommandLinks method is where all hotkeys (for keyboard) are set up. They update the SyntaxEditor.CommandLinks property. So if you wish to alter them you could override that method and change them after the base method is called. The documentation has a topic that lists all the default command links.

For the mouse wheel, you'd have to override SyntaxEditor.OnMouseWheel and not call the base method if you don't want our default logic to kick in.

Protected Overrides Sub OnMouseWheel(ByVal e As System.Windows.Forms.MouseEventArgs)
'Zoom the font size or scroll the text when Mouse Wheel is rotated
If My.Computer.Keyboard.CtrlKeyDown Then
ChangeZoomFactor(e.Delta > 0) 'Zoom
Else
MyBase.OnMouseWheel(e) 'Scroll
End If
End Sub

This handles zooming vs scrolling if the Ctrl key is down, but you can do anything you want while handling the MouseWheel event.

For Alt vs Ctrl to perform block selection see the first response in this thread.(I didn't try the solution as I don't see any issue with simply using Alt. There were however issues with block selection itself but these were fixed a while back.)

I stumbled across this thread and wanted to know if the mouse intreraction code had changed since. I'm trying to do a simple toggle button to switch between the continuous stream selection mode and the block selection mode.

The idea is that when the block mode is selected by the user, the user's normal selection (only holding down left mouse button) will select with the Block mode.

Is this possible without having to do it all manually?

EDIT: Using Alt+Arrows on Windows10 inserts symbols ♦◘♠☻. This also happens with Alt+Shift+Arrows in the SyntaxEditor when trying to do the 'SelectBlockDownAction' etc. Any solution to not add these symbols after that operation?

No, nothing is really different in the mouse down event handling logic and how it looks at keyboard modifier keys. There isn't anything built into SyntaxEditor meant to support a "toggleable" selection mode in regards to modifier key-less mouse-based selection.

I'm curious to know more about the Alt+Shift+Arrow keys inserting those odd symbols. That's not something I'm seeing happen when I try to reproduce it. Are you on a special culture keyboard setup perhaps? Can you provide any info as to why those might be getting inserted for your culture?

Ahh ok that explains it. You are using the number pad arrow keys and that's what's causing it. Those won't work because the Windows operating system has a very low-level intercept for Alt+NumPad(key) where it inserts a character with the ASCII code that you type with the numbers. For instance, Alt+6 types a "spade" character which is ASCII 6, and Alt+6,5 types an "A" character since that is ASCII 65.

This feature of Windows happens at a low level and unfortunately we haven't seen a way to intercept it since the UI framework is never passed those keys in KeyDown. The keyboard-based block selection hotkeys are meant to be used with the standalone arrow keys (not on the number pad).

I tried it on 3 machines and its the same behavior. It also does the same thing with Notepad++, Visual Studio, etc.

Currently looking for a work around since doing so replaces the selected text with the symbol. So far I'm rebinding those controls with the Syntax Editor InputBindings but would like to use the default ones.

I couldn't see what setting on the computer could cause this, the machines pretty much have the default settings.

It sounds like it's a low-level Windows issue. I would never expect the normal 4 arrow keys to behave like the numpad arrow keys when paired with Alt. That's so bizarre.

I'm curious if you see the KeyDown event firing when you press the Shift + Alt + (arrow key)? When I had tested that with the Shift + Alt + NumPad arrow keys, I got KeyDown events for Shift and then Alt, but never the arrow keys. I suspect the same is happening for you with the normal 4 arrow keys too.

I've done some Internet searching to see if there is a Windows option for this but haven't found anything. And like I said, I've never seen that behavior for the normal 4 arrow keys on computers I've ever used.

Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 9 months ago,
which was after the last post in this thread.