【问题标题】:Show sub-buttons of TActionToolBar when top level button is clicked单击顶级按钮时显示 TActionToolBar 的子按钮
【发布时间】:2012-11-04 12:03:21
【问题描述】:

我有一个使用 TActionToolBar 和 TActionManager 的工具栏。按钮具有子按钮,单击按钮右侧的小向下箭头可以使用这些子按钮。全部由 VCL 管理,运行良好。

我想在单击顶级按钮时显示子按钮。现在,我只需要单击小箭头,但我希望整个按钮都这样做。

有可能吗?

谢谢

【问题讨论】:

    标签: delphi c++builder vcl


    【解决方案1】:

    听起来您可以使用 DropDown 控件,该控件在选择项目时起作用。除此之外,只需将代码放在 OnButtonClick 方法中即可模拟单击的向下箭头。

    【讨论】:

      【解决方案2】:

      我设法使以下项目适用于我的项目。我找不到直接引用在 ActionBar 上创建的按钮的方法。但是,ActionComponent 设置为在运行时创建的按钮。

      这当然必须是一个动作本身才能连接到动作栏上的主按钮,子项所在的位置。

      procedure TReportPlugin.actMyDropdownExecute(Sender: TObject);
      var
        ActionButton: TCustomDropDownButton;
      begin
        inherited;
      
        if (Sender is TAction) then
        begin
      
          if (Sender as TAction).ActionComponent is TCustomDropDownButton then
          begin
            ActionButton := (Sender as TAction).ActionComponent as TCustomDropDownButton;
            ActionButton.DropDownClick;
          end;
      
        end;
      end;
      

      【讨论】:

        猜你喜欢
        • 2021-04-07
        • 1970-01-01
        • 1970-01-01
        • 2013-05-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多