Recent

Author Topic: [Solved] Add TAction programmatically  (Read 358 times)

Edson

  • Hero Member
  • *****
  • Posts: 1302
[Solved] Add TAction programmatically
« on: July 05, 2022, 04:30:54 am »
Hi.

Is it possible to add a new TAction to an ActionList control programmatically?  How?

I was searching about it with no success.


Thanks
« Last Edit: July 05, 2022, 05:34:56 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Wallaby

  • Jr. Member
  • **
  • Posts: 78
Re: Add TAction programmatically
« Reply #1 on: July 05, 2022, 04:51:47 am »
Pretty simple:

Code: Pascal  [Select][+][-]
  1.  Action := TAction.Create(YourActionList);
  2.  Action.ActionList := YourActionList;
  3.  Action.ShortCut := ...
  4.  Action.Caption := ...
  5.  Action.OnUpdate := ...
  6.  Action.OnExecute := ...

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Add TAction programmatically
« Reply #2 on: July 05, 2022, 05:34:38 am »
Thank you.

I was looking for a TACtionList.Add() method. But it wasn't the way.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018