Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owner Vs PArent and Taction shortcuts on Frames

Tags:

delphi

owner

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.

like image 381
Fred Avatar asked Mar 16 '11 07:03

Fred


2 Answers

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.

like image 89
Uwe Raabe Avatar answered Sep 27 '22 23:09

Uwe Raabe


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.

like image 23
Uli Gerhardt Avatar answered Sep 28 '22 01:09

Uli Gerhardt