我想在单击任何功能区按钮时将功能区的所有 TAction 对象的“已检查”属性重置为 false,然后仅在按下的按钮上将其设置为 true。但是我还没有找到一种方法来访问 ActionManager 的 Actions 的所有“已检查”属性。我想我需要遍历动作管理器的动作列表……但是,我还没有找到正确的方法。如果有人能给我一些提示,我会很高兴。
谢谢!
TActionManager
的后裔TCustomActionList
,所以无论你对后者做什么,你都可以对前者做。它有两个您需要使用Actions
的属性,它是数组属性,可让您访问列表的所有操作,以及ActionCount
,它告诉您有多少。使用它们编写一个普通的循环,如下所示:
var
i: Integer;
Contained: TContainedAction;
Action: TCustomAction;
begin
for i := 0 to Pred(ActionList.ActionCount) do begin
Contained := ActionList[i]; // shorthand for ActionList.Actions[i]
if not (Contained is TCustomAction) then
continue; // Doesn't have Checked property
Action := TCustomAction(Contained);
Action.Checked := False;
end;
end;
动作列表可以包含很多种动作,它们并不都具有Checked
属性。该属性是在 中引入的TCustomAction
,因此上面的代码也过滤掉了不属于该类的东西。