Recent

Author Topic: How to use ExecuteAction?  (Read 3105 times)

flaza

  • Jr. Member
  • **
  • Posts: 59
How to use ExecuteAction?
« on: November 24, 2013, 02:04:02 pm »
I have a small program attached. In that program I have 3 actions. Action3 is bound to the form. After a mouseclick anywhere in the form Action2 (bound to Button2) must be executed. The same in the CheckGroup, when itemclicked, Action 1 (bound to button1) must be executed.

I can succeed in 2 ways.
1. I call directly the procedure Action2Execute (or Action1Execute).
2. I use the statement Button2.Action.Execute.
Why can't I use ExecuteAction? When I do, nothing happens. And ExecuteActions seems to me a more elegant way.

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: How to use ExecuteAction?
« Reply #1 on: December 10, 2013, 05:33:33 pm »
From the help for TComponent.ExecuteAction:

ExecuteAction checks whether Action handles the current component, and if yes, calls the ExecuteAction method, passing itself as a parameter. The function returns True if the action handles the current component.

Code: [Select]
procedure TForm1.CheckGroup1ItemClick(Sender: TObject; Index: Integer);
begin
  //Action1Execute(Sender);
  //Exit;
  Button1.SetFocus;
  if Button1.ExecuteAction(Action1) then ShowMessage('True') else ShowMessage('False');
  CheckGroup1.SetFocus;
end;

I get a False returned - have not investigated further...
Lazarus 2.0.4/FPC 3.0.4/Win 64

 

TinyPortal © 2005-2018