小编mrC*_*ass的帖子

TAction.ShortCut 在动态创建的 TAction 中不起作用

在Delphi XE5中:我的窗体上有一个TActionManager(称为ActionManager)和一个TRibbon(称为Ribbon)。我正在添加这样的自定义操作:

ActionBar := ActionManager.ActionBars.Add;
newAction := TAction.Create(MainForm.ActionManager);
newAction.Name := 'Topics';
newAction.Caption := 'Topics';
newAction.OnExecute := MainForm.HelpTopicsItemClick;
newMenu := ActionBar.Items.Add;
newMenu.Action := newAction;
newAction.ShortCut := TextToShortCut('F1');
Run Code Online (Sandbox Code Playgroud)

之后,我将它们放在页面/选项卡和组中的功能区上:

rp := TRibbonPage.Create(ActionManager);
rp.Parent := Ribbon;
Ribbon.AddTab(rp).Caption := 'Help';
rg := TRibbonGroup.Create(ActionManager);
rg.Parent := rp;
rg.ActionManager := ActionManager;
rg.Caption := 'Help';
rg.ActionClient := ActionBar;
Run Code Online (Sandbox Code Playgroud)

当我单击它时,该操作工作正常,但是当我按“F1”时,什么也没有发生。当我使用 Delphi 编辑器手动添加操作时,快捷方式工作正常。

我已经尝试过: newMenu.ShortCut := newAction.ShortCut

这没有帮助。我缺少什么?

delphi ribbon shortcut delphi-xe5

3
推荐指数
1
解决办法
1185
查看次数

标签 统计

delphi ×1

delphi-xe5 ×1

ribbon ×1

shortcut ×1