框架上的所有者与父母和 Taction 快捷方式
我有一个带有面板的表格。
我在运行时创建框架,并通过将框架的父属性设置为面板来将它们显示在面板上。
创建面板时,我不设置所有者属性,因为我自己管理框架的生命周期。
到目前为止我没有遇到任何问题。接下来,我在框架上放置了一个 TActionList,其中包含一些操作快捷方式。
我发现,直到我将框架的所有者属性设置为面板后,我的操作才会执行。
有人可以向我解释一下吗?我认为所有者属性只是负责释放子组件的组件,而不负责转发关键事件。
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 some 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
表单的快捷方式处理在
TCustomForm.IsShortCut
中完成,其中迭代组件,其中包括 TActionList。虽然框架不属于表单,但在迭代过程中找不到框架上的任何操作列表。您可以通过在框架附加到面板时将操作列表或整个框架的所有者更改为表单来解决此问题。创建后更改所有者可以使用InsertComponent
来完成。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 withInsertComponent
.所有者主要关注终身管理。但至少有 poOwnerFormCenter 将 Owner 用于完全不同的目的。你可能偶然发现了另一个目的。
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.