我正在尝试动态添加操作项,我可以添加该项目,并且当我这样做时它可以工作:
HostActionItem := ActionManager.ActionBars[0].Items[0].Items[2];
NewItem := HostAction.Items.Add;
NewItem.Action := MyActionToPerform;
NewItem.Caption := Description;
NewItem.ImageIndex := 1;
NewItem.Tag := 13;
但是,当动作 Execute 方法触发时,我尝试从 Sender 对象中获取 ActionComponent,如下所示:
if (Sender is TAction) then
tag := (Sender As TAction).ActionComponent.Tag;
但 ActionComponent 始终为零。为什么 ActionComponent 没有被初始化?