如何在 SapToolbarControl 中获取按钮的按钮 ID? [英] How to get the button ID of a button in SapToolbarControl?
问题描述
我有一个 SapToolbarControl (MicroFocus) 并且我想按下该工具栏的一个按钮.
I have a SapToolbarControl (MicroFocus) and I want to press a button of that toolbar.
但是,任何方法 selectButton()
、selectContextButton()
或 pressContextButton()
需要一个参数称为 id
,类型为 String
.
However, any of the methods selectButton()
, selectContextButton()
or pressContextButton()
require a parameter called id
of type String
.
我无法找到从哪里获取 ID.
I was unable to find out where to get the ID from.
我在 Eclipse Luna 中使用 Silk4J 16 Hotfix 2.这也发生在 Silk4J 15.5 中.
I am using Silk4J 16 Hotfix 2 in Eclipse Luna. This also happens in Silk4J 15.5.
推荐答案
SAP 自动化 API 提供了一种名为 GetButtonId
的方法,该方法未由 Silk4J 实现.该方法将工具栏中按钮的位置作为输入.
The SAP automation API provides a method called GetButtonId
which is not implemented by 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;
}
这篇关于如何在 SapToolbarControl 中获取按钮的按钮 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!