Question

How to change Keyboard shortcut mappings

Posted 6 years ago by Avatar Mike Dempsey - Sr. Developer, Teradata Corp

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)

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

Hi Mike,

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.


Actipro Software Support
Posted 6 years ago by Mike Dempsey - Sr. Developer, Teradata Corp

Thanks, I think that's what I needed.

I have not yet derived my own class from SyntaxEditor but I will need to do that since each 'Query' will need to keep certain meta-data anyway.

Posted 3 years ago by Michael Andrews - Software Engineer, Breault Research

Hi, the question above concerning Block selection via the mouse was not answered:

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

The use of the Alt key is problematic and would like to change the block selection using the ctrl key as mentioned above. Please advice.

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

Hi Michael,

I'm sorry but the mouse interaction code is defined in a large 'if'...'else if' block in our EditorView MouseDown logic.  There isn't any option at this time to alter how that all functions.

Ctrl+clicks handle word selection and Atl+clicks handle block selection in the same way Visual Studio does things.  What specifically is problemmatic with using Alt keys?


Actipro Software Support
Posted 3 years ago by Mike Dempsey - Sr. Developer, Teradata Corp

For mouse wheel actions you can do something like:

    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.) 

Information The latest build of this product (2018.1 build 0340) was released 4 months ago, which was before the next post in this thread.
Posted 3 months ago by Frederic Gregoire

Hi,

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? 

Thanks.

[Modified 3 months ago]

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Frederic,

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?


Actipro Software Support
Posted 3 months ago by Frederic Gregoire

Using : English (Canada) US Keyboard.
I tried with other keyboard cultures and I am getting the same results: French (Canada) Canadian Multilingual Standard keyboard

This is the info from a powershell of the current Windows 10 I am on:

PS Z:\> Get-Culture | Format-List -Property *
Parent : en
LCID :
KeyboardLayoutId : 4105
Name : en-CA
IetfLanguageTag : en-CA
DisplayName : English (Canada)
NativeName : English (Canada)
EnglishName : English (Canada)
TwoLetterISOLanguageName : en
ThreeLetterISOLanguageName : eng
ThreeLetterWindowsLanguageName : ENC
CompareInfo : CompareInfo - en-CA
TextInfo : TextInfo - en-CA
IsNeutralCulture : False
CultureTypes : SpecificCultures, InstalledWin32Cultures, FrameworkCultures
NumberFormat : System.Globalization.NumberFormatInfo
DateTimeFormat : System.Globalization.DateTimeFormatInfo
Calendar : System.Globalization.GregorianCalendar
OptionalCalendars : {System.Globalization.GregorianCalendar, System.Globalization.GregorianCalendar}
UseUserOverride :
IsReadOnly :

This is a problem with the default Alt + Numpad / Keypad ascii entry from Microsoft.

Let me know if you manage to reproduce it or find a workaround

Thanks

[Modified 3 months ago]

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Frederic,

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).


Actipro Software Support
Posted 3 months ago by Frederic Gregoire

I am using the arrow keys. Not the ones from the numpad, but it has the same result.

If you look at this image : https://www.bing.com/images/search?view=detailV2&ccid=2LDcz%2bu7&id=9E5C58730126727FB81883ACD8617BD666C888BE&thid=OIP.2LDcz-u7Ik28SX7E6JXl2QHaC8&mediaurl=http%3a%2f%2fwww.informationq.com%2fwp-content%2fuploads%2f2013%2f10%2fcomputer-keyboard-layout.jpg&exph=368&expw=927&q=keyboard&simid=608017262335033537&selectedIndex=5&ajaxhist=0

Its the arrow keys right below the 'End'.

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

That's odd, I've never heard of those arrow keys working like the number pad arrow keys with Num Lock off.  

Does this same thing happen when you type into Notepad with those non-numpad arrow keys?

Have you tried this on multiple machines?  I wonder if you have some setting on your computer that is causing that strange behavior for the non-numpad arrow keys.


Actipro Software Support
Posted 3 months ago by Frederic Gregoire

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.

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

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

Add a Comment

Please log in to a validated account to post comments.