Book a Demo

Author Topic: Escape key messes up my RichTextBox  (Read 4105 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Escape key messes up my RichTextBox
« on: September 06, 2011, 06:41:52 pm »
Hi,

I have a Windows.Forms.RichTextBox in a control that I added as an add-in window in EA.
This all works nice untill I press the escape key. Then suddenly my RichTextBox doesn't accept enter or tab keys, and it doesn't launch the TextedChanged events anymore.
I've been trying to figure out what happens for a while now but I can't find anything.
I still receive all the key events for the enter key, the RichTextBox is not disabled or readonly, and it still has the focus?!?
Is EA doing something as a reaction to the escape key that somehow messes up my RichTextBox?
When running this RichTextBox in my own window I don't have any such problems.

Anyone an idea? I've also sent a bug report to Sparx.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Escape key messes up my RichTextBox
« Reply #1 on: September 07, 2011, 08:37:16 am »
Your richtextbox isn't embedded into a dialog by any chance by any chance is it?

I've usually seen that kind of behavior when there is an embedded dialog The usual suspect of that behavior is by having an embedded dialog. The default behavior of escape in a dialog is to close the dialog, which for an embedded dialog leaves it in a bad state. You'd also end up with drawing issues if you resized it if that is the problem.

I've had a look, and EA doesn't appear to wrap add-in controls in a dialog so this wouldn't be the problem on our end.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Escape key messes up my RichTextBox
« Reply #2 on: September 14, 2011, 07:26:44 pm »
I found it!

I finally figured out that, for some reason the "HandleDestroyed" event was being launched by the RichTextBox after I pressed escape.
That lead me to believe that there was some cleanup process going on after pressing escape.
I've then overridden the ProcessDialogKey to disable handling of the escape key like this:

Code: [Select]
       protected override bool ProcessDialogKey(Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                return true;
            }
            else
            {
                return base.ProcessDialogKey(keyData);
            }
        }

Which then solved my problem.  :)

Geert