2012-11-15 60 views
4

我有一個使用TActionToolBar和TActionManager的工具欄。一個按鈕具有可用的子按鈕,單擊按鈕右側的小向下箭頭。全部由VCL管理並且工作正常。單擊頂級按鈕時顯示TActionToolBar的子按鈕

我想單擊頂級按鈕時顯示子按鈕。現在,我需要點擊小箭頭,但我希望整個按鈕的功能相同。

可能嗎?

謝謝

回答

0

聽起來像是你可以使用當一個項目被選中充當一個下拉控件。除此之外,只需將代碼放在OnButtonClick方法中即可模擬被單擊的向下箭頭。

0

我設法讓我的項目工作如下。我無法找到直接引用在ActionBar上創建的按鈕的方法。然而,ActionComponent被設置爲在運行時創建的按鈕。

這當然必須是一個Action本身,以連接到操作欄上的主要按鈕,其中附加了子項目。

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;