Jump to content
Sign in to follow this  
Squall_FF8

Delphi Mystery: Edit vs Action

Recommended Posts

Hey guys,
I found the following mystery. Could you help me to solve it?

A VCL application with Main form. On that form we have Edit and panel that different forms attach to it (one at a time, depending on a context).
- The Edit has OnKeePress that handle, when Enter is used.
- Attached forms have Action that has short-key: Enter.
- 7 of Attached forms are Auto created (in the project).
- 2 of Attached forms are created only once per use in run time.
The mystery: What will happen if the Edit has a focus and I hit Enter? Whose handler will be triggered - Edit or attached window?

Well at run time, if I have attached one of the 7 - Edit handler respond. If I have attached one of the 2 - their handler respond.
So I guess my question is WHY? Why the difference between 7 and 2 windows? What is going on under the hood?

Edited by Squall_FF8

Share this post


Link to post
19 minutes ago, Squall_FF8 said:

 2 of Attached forms are created only once per use in run time.

Where? In the Main form?

Created with "self" in Main form?

The Autocreated with Application.CreateForm in *.dpr?

Edited by Die Holländer

Share this post


Link to post
1 minute ago, Die Holländer said:

Where in the Main form?

Created with "self" in Main form?

The Autocreated with Application.Create in *.dpr?

Yes, to both questions, The 2 are created on demand and reused after that (if/when needed)

Share this post


Link to post
7 minutes ago, Die Holländer said:

Created with "self" in Main form?

Hmm are you suggesting, that because Main is the owner of the 2 windows (and the Edit), the Actions have higher precedence?
(and thus difference in behavior)

Share this post


Link to post

Perhaps you can get some understanding from this old article of mine. Key processing was already complex at the time the article was written and it only got more so with later additions, e.g. the modified MDI support introduced in recent versions of Delphi.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×