简体   繁体   English

如何在SapToolbarControl中获取按钮的按钮ID?

[英]How to get the button ID of a button in SapToolbarControl?

I have a SapToolbarControl (MicroFocus) and I want to press a button of that toolbar. 我有一个SapToolbarControl(MicroFocus) ,我想按下该工具栏上的一个按钮。

However, any of the methods selectButton() , selectContextButton() or pressContextButton() require a parameter called id of type String . 但是,任何方法selectButton()selectContextButton()pressContextButton()都需要一个名为id的参数,类型为String

I was unable to find out where to get the ID from. 我无法找到从哪里获得ID。

I am using Silk4J 16 Hotfix 2 in Eclipse Luna. 我在Eclipse Luna中使用Silk4J 16 Hotfix 2。 This also happens in Silk4J 15.5. 在Silk4J 15.5中也会发生这种情况。

The SAP automation API provides a method called GetButtonId which is not implemented by Silk4J. SAP自动化API提供了一个名为GetButtonId的方法,该方法未由Silk4J实现。 The method takes the position of the button within the toolbar as input. 该方法将按钮在工具栏中的位置作为输入。

You can invoke the method yourself with the following code: 您可以使用以下代码自己调用该方法:

public String getButtonId(SapToolbarControl toolbar, int position)
{
    Object[] params = new Object[1];
    params[0] = position;
    Object buttonId = toolbar.invoke("GetButtonId", params);
    return (String) buttonId;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM