This adds an ActionClientItem at runtime from a stringList:
var
ActionClient: TActionClient;
ChildItem: TActionClientItem;
if FileExists( ARecentFilesFilename ) then
begin
ARecentFilesList.LoadFromFile( ARecentFilesFilename );
// remove any duplicates
RemoveDuplicates( ARecentFilesList );
for i := 0 to ARecentFilesList.Count - 1 do
begin
Ribbon1.AddRecentItem( ARecentFilesList.Strings[ i ] );
ActionClient := RibbonGroup1.ActionControls[ 1 ].ActionClient;
ChildItem := ActionClient.Items.Add;
ChildItem.Tag := i;
ChildItem.Action := ActionOpenFileFromButton1;
ChildItem.Caption := ARecentFilesList.Strings[ i ];
end;
end;
This attempts to get the filename of the selected ActionClientItem but it fails.
procedure TMainForm.ActionOpenFileFromButton1Execute( Sender: TObject );
var
ActionClient: TActionClient;
ChildItem: TActionClientItem;
AFilename: string;
AIndex: integer;
begin
ActionClient := RibbonGroup1.ActionControls[ 1 ].ActionClient;
AIndex := ActionClient.Index;
ChildItem := ActionClient.Items.ActionClients[ AIndex ];
AFilename := ChildItem.Caption;
OpenZipFileFromChildButton( AFilename );
end;
What am I doing wrong? Is there a different way do do this?