tactionmanager

How do I programatically add actions to an Action Manager in Delphi 2010

会有一股神秘感。 提交于 2019-12-10 11:22:55
问题 I am trying to dynamically add actionitems, I can add the item and it works when I do this: HostActionItem := ActionManager.ActionBars[0].Items[0].Items[2]; NewItem := HostAction.Items.Add; NewItem.Action := MyActionToPerform; NewItem.Caption := Description; NewItem.ImageIndex := 1; NewItem.Tag := 13; However, when the action Execute method fires I attempt to get the ActionComponent from the Sender object like this: if (Sender is TAction) then tag := (Sender As TAction).ActionComponent.Tag;

How do I programatically add actions to an Action Manager in Delphi 2010

霸气de小男生 提交于 2019-12-06 05:42:47
I am trying to dynamically add actionitems, I can add the item and it works when I do this: HostActionItem := ActionManager.ActionBars[0].Items[0].Items[2]; NewItem := HostAction.Items.Add; NewItem.Action := MyActionToPerform; NewItem.Caption := Description; NewItem.ImageIndex := 1; NewItem.Tag := 13; However, when the action Execute method fires I attempt to get the ActionComponent from the Sender object like this: if (Sender is TAction) then tag := (Sender As TAction).ActionComponent.Tag; But the ActionComponent is always nil. Why is the ActionComponent not being initialised? Sertac Akyuz