Cassandra87
Cassandra87

Reputation: 91

Delphi memo box won't capture Return key

I have an application with two forms, both are dialogs and they both have memo boxes in them and they both have an OK button on them, however one dialog behaves differently from the other - if I am in the memo area and i type something and then press enter, the form closes but in the other form it goes to the next line in the memo (this is how I want it to behave).

I don't know how to fix the other form so that pressing enter inside the memo does not close it but makes it go to the next line. I even copied the memo component from the 'good' to the 'bad' form and it still does that, also compared the form properties but they are the same! Any idea why this is happening?

Upvotes: 1

Views: 1816

Answers (1)

HeartWare
HeartWare

Reputation: 8243

Two possibilities:

1) The Memo needs to have the WantReturn in order for the memo itself to process the RETURN key.

2) Check any KeyPress/KeyDown/KeyUp handler on the form that doesn't work to see if they process a RETURN key. If the form has KeyPreview=TRUE then the form's keyboard handler will be executed BEFORE the memo's and if the form's keyhandler processes RETURN then the memo will never see it.

Upvotes: 4

Related Questions