1

在此处输入图像描述

有4个切换按钮,当我点击一个时,其他3个没有点击 例如,当我点击公开时,机密的点击将被删除。只能选择 1 个。

 <toggleButton id="textButtonpublic" getLabel="getpublic" getImage="getcolor" onAction="PublicAction" getVisible="getvisiblepublic"  getPressed="GetPressedPublic"   />

public void PublicAction(IRibbonControl control, bool pressed){
GetPressedConfidential();}


 public bool GetPressedConfidential(IRibbonControl control)
    {
        return false;
    }

当我调用 GetPressedConfidential 方法时它不起作用。

4

1 回答 1

2

如果功能区按钮来自您的加载项,您需要使用接口的InvalidateInvalidateControl方法,该方法IRibbonUI允许使功能区用户界面上的单个控件或所有控件的缓存值无效。

例如,如果加载项编写器为按钮实现 getImage 回调过程,则调用该函数一次,加载图像,然后如果需要更新图像,则使用缓存的图像而不是调用过程。此过程对控件保持不变,直到加载项使用 InvalidateControl 方法发出缓存值无效的信号,此时,再次调用回调过程并缓存返回响应。

getPressed回调具有以下控件签名toggelButton

C#: bool GetPressed(IRibbonControl control)

VBA: Sub GetPressed(control As IRibbonControl, ByRef returnValue)

C++: HRESULT GetPressed([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfPressed)

Visual Basic: Function GetPressed(control As IRibbonControl) As Boolean

Fluent UI(又名 Ribbon UI)在以下文章中有深入描述:

于 2021-06-23T14:56:35.810 回答