Posted 17 years ago by Thane Plummer
What is the best way to trap the ENTER key? When using the key events fired by the SyntaxEditor, the ENTER key is consumed before these events (KeyDown, KeyPress, and KeyUp). I suspect that the thing to do is create a Trigger, or am I missing something?

I need to muck around with every line after ENTER is pressed, so obviously I need to know about this event.

Thanks in advance.

Comments (2)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
To handle that you'd have to create a class that inherits SyntaxEditor and override ProcessCmdKey. The problem is that the ENTER key gets mapped to an action and is consumed before any of the other key events fire. This is something we'd like to possibly change. If you have any suggestions, please post them.

Actipro Software Support

Posted 17 years ago by Thane Plummer
That does it! Thanks.

You may consider allowing the Enter-key to generate a trigger. That would simplify things a bit, although the component override is trivial. In case anyone else needs to do this, here's what you do:

1. In VS .NET right click on your project and select "Add New Item..." from the popup menu.
2. Select "Inherited User Control".
3. Browse to find the SyntaxEditor control, select it, and name your new class.
4. Here's the code you need to add:

        // Here's the magic override
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
            if (keyData == Keys.Enter)
                MessageBox.Show("Got it!");
            return base.ProcessCmdKey (ref msg, keyData);
The latest build of this product (v2020.1 build 0403) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.