我有一个带有 4 个按钮的ribbonBar。现在,在单击的每个按钮上,我都想执行一些操作。但我遇到的问题是如何知道单击了哪个按钮。有人可以指导我。下面是我的代码和屏幕截图。顺便说一下,我使用的是 Button 而不是展示中所示的 IconButton。如果我使用这个按钮可以吗??
public class DBilling implements EntryPoint
{
@Override
public void onModuleLoad()
{
VLayout vLayout = new VLayout();
vLayout.setWidth100();
RibbonBar ribbonBar = new RibbonBar();
ribbonBar.setLeft(0);
ribbonBar.setTop(0);
ribbonBar.setWidth100();
ribbonBar.setMembersMargin(2);
ribbonBar.setLayoutMargin(2);
RibbonGroup orderGroup = new RibbonGroup();
orderGroup.setTitle("New Order");
orderGroup.setRowHeight(60);
orderGroup.addControl(getButton("Order", "order", false));
RibbonGroup reportGroup = new RibbonGroup();
reportGroup.setTitle("Report");
reportGroup.setRowHeight(60);
reportGroup.addControl(getButton("Report", "report", false));
RibbonGroup productGroup = new RibbonGroup();
productGroup.setTitle("New Product");
productGroup.setRowHeight(60);
productGroup.addControl(getButton("Product", "cookies", false));
RibbonGroup systemGroup = new RibbonGroup();
systemGroup.setTitle("System");
systemGroup.setRowHeight(60);
systemGroup.addControl(getButton("System", "system", false));
ribbonBar.addMember(orderGroup);
ribbonBar.addMember(reportGroup);
ribbonBar.addMember(productGroup);
ribbonBar.addMember(systemGroup);
vLayout.addChild(ribbonBar);
vLayout.draw();
}
private Button getButton(String title, String iconName, boolean vertical)
{
final Button cssButton = new Button(title);
cssButton.setShowRollOver(true);
cssButton.setShowDisabled(true);
cssButton.setShowDown(true);
cssButton.setIcon(iconName + ".png");
cssButton.setIconSize(32);
cssButton.setWidth(120);
cssButton.addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
SC.say(event.getSource().toString());
}
});
return cssButton;
}