开发者

Owner Vs PArent and Taction shortcuts on Frames

I have a form with a panel.

I create frames at runtime and display them on the panel by setting frame's parent property to the panel.

When creating panels I do not set the owner property because i manage myself the lifetime of the frame.

Until now i got no problem. Next I put an TActionList on the frame with som开发者_StackOverflowe shortcuts on the actions.

I found that my actions did not execute until I set the owner property of the frame to the panel.

Can someone can explain me that ? I thought that owner property was just about wich component is responsible to free the children components, and not responsible to forward key events.


The shortcut handling of the form is done in TCustomForm.IsShortCut, where the components are iterated which includes TActionLists. While the frame is not owned by the form, none of the actionlists on the frame are found during the iteration. You can workaround this by changing the owner of the actionlist or the complete frame to the form while the frame is attached to the panel. Changing the owner after creation can be done with InsertComponent.


Owner is mostly about lifetime management. But there is at least poOwnerFormCenter which uses Owner for a totally different purpose. And you probably stumbled over another purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜