Shortcut Keys KeyTyped/KeyTyping

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
I'm trying to add my own shortcutkeys, but somehow it doesn't work (proper)
Private Sub SyntaxEditor1_KeyTyped(sender As Object, e As ...) Handles SyntaxEditor1.KeyTyped
   Select Case e.KeyData
      Case Keys.Control And Keys.Alt And Keys.D5
         MsgBox("money")
         SyntaxEditor1.SelectedView.SelectedText = "money"
      Case Keys.Control And Keys.Alt And Keys.Space
         MsgBox("ok")
         SyntaxEditor1.SelectedView.SelectedText = "CTRL+ALT+SPACE pressed"
End Select
1) The CTRL+ALT+5 works, but it also shows the €-sign "money€", which I don't want. I only want to see "money".
2) the second shortcut doesn't do anything.

Do you see what I'm doing wrong here?
Thanks in advance.

Comments (8)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
1) You probably want to handle KeyTyping instead since you can set e.Cancel to prevent further processing of the keypress in that case.

2) Ctrl+Alt+Space fires for me ok. But you are using the 'And' operator between Keys values and probably mean to be using 'Or' instead since those values should be bitwise OR'ed, not AND'ed.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Using the AND operator, was a bit stupid of me, but the € sign is still showing. Please bear in mind that the standard windows-shortcut of the €-sign is ctrl+alt+5.

I'm creating a handler with the following argument:
.....(ByVal sender As Object, e As ActiproSoftware.SyntaxEditor.KeyTypingEventArgs)
Select Case e.KeyData
Case Keys.Control Or Keys.Alt Or Keys.D5
xSyn.SelectedView.SelectedText = "Euro-sign"
e.cancel=true
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmmm... I wonder if there is an issue translating the KeyDown/KeyPress events to KeyTyping. Try this, handle KeyDown and set e.Handled on it if you detect your key. If that doesn't catch it, try KeyPress instead and set e.Handled on it. Both of those triggger KeyTyping if they aren't handled.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Sorry, but I can't get it to work :cry: (Thanks for the help so far btw.)
Perhaps someone has a proper solution for this.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you'd like us to help further then please make a new simple sample project that shows the issue and email it over. Be sure to rename the .zip file extension so it doesn't get spam blocked when you send it to us. Also let us know what culture your keyboard is in.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
No problem. Will send it tomorrow.
Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Forgot it a little bit. Sorry for that: http://www.mediafire.com/?b7wbgrdac343m6p
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the sample. I tried to get it working how you wanted in the standard WinForms RichTextBox in your sample but couldn't do so. If it can't work there then it won't work in SyntaxEditor since we use the same sort of events.

It seems like the system itself fires KeyDown/KeyUp for the key combination but the KeyPress fires separately with the Euro sign. If you switch keyboard layouts (we tried using French), it's inserting a [ instead of a Euro.

The only way I imagine you might be able to work around this is to set a flag when Ctrl+Alt+D5 is detected in KeyDown and clear it in KeyUp. Then in KeyPress, handle that event if the flag is set, thus preventing the character from being 'typed'.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.