Stano 143 Posted April 11, 2022 (edited) I always create all Actions only once. They live during the life of the instance. I define an OnExecute event in the component and, if necessary, at design time in the instance I want this behavior on the runtime: if the event is only in the component, it will not always exist, so it will be triggered if the event is only in the instance, it will fire if the event is in the component as well as in the instance, then the event in the instance is triggered first and the event in the component is called with inherited Classic behavior About component TjstVstDBNavigator = class(TCustomActionToolBar) strict private FAcnMan: TAcTionManager; Current status In the component, I assign an Action OnExecute to each. As a result Logically, only the event in the component always fires Event in the instance will never run Edited April 11, 2022 by Stano Share this post Link to post
Stano 143 Posted April 11, 2022 I did not write that events must have access to component fields. Otherwise they are worthless. Share this post Link to post
Stano 143 Posted April 11, 2022 I found out it could also be a Button.OnClick. Which is easier. Share this post Link to post
David Heffernan 2354 Posted April 11, 2022 5 hours ago, Stano said: I want this behavior on the runtime: if the event is only in the component, it will not always exist, so it will be triggered if the event is only in the instance, it will fire if the event is in the component as well as in the instance, then the event in the instance is triggered first and the event in the component is called with inherited I cannot understand what you mean by event in component or instance. In fact I can't make any sense out of this. Share this post Link to post
Stano 143 Posted April 11, 2022 (edited) In component - code written hard during component design. E.g. DataSource.Post itself In the instance - a component on the form and it is necessary to extend the event. E.g. for DataSource.Post do the data check first Edited April 11, 2022 by Stano Share this post Link to post
Stano 143 Posted April 11, 2022 I think I've found a solution TjstVstDBNavigator = class(TCustomActionToolBar) type Ta = class(TAction) private bb: TjstVstDBNavigator; public constructor Create(AOwner: TComponent); override; end; constructor TjstVstDBNavigator.Ta.Create(AOwner: TComponent); begin inherited; bb := TjstVstDBNavigator(Owner); bb.AcnMan; // It knows AcnMan end; This is a principle. Now I can override the event. I believe it will work. Share this post Link to post
Stano 143 Posted April 11, 2022 Premature joy. I forgot that OnExecute is a property! Share this post Link to post
Attila Kovacs 631 Posted April 11, 2022 8 minutes ago, Stano said: Premature joy. I forgot that OnExecute is a property! There is always a virtual DoXY behind the OnXY. Share this post Link to post
Stano 143 Posted April 11, 2022 If he overrides it, will it work for me normally? That would make me very happy. Share this post Link to post