在 GWT 中以编程方式调用 click() 函数 [英] call click() function as programmatically in GWT
本文介绍了在 GWT 中以编程方式调用 click() 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 GWT 中为 Button 调用单击事件函数...我试过这段代码,但它不起作用..
i want to call click event function for Button in GWT... I tried this code but it is not working..
Button btnAddField = new Button();
btnAddField.setText("Add");
btnAddField.setWidth("225px");
btnAddField.addClickHandler(new btnAddFieldButtonClickListener());
private class btnAddFieldButtonClickListener implements ClickHandler{
public void onClick(ClickEvent event) {
Window.alert("Called Click Event");
}
}
这个函数会在点击按钮时调用但是调用这个函数时不调用btnAddField.click()
this function wiil call at click the button
but it does not call when call this function btnAddField.click()
推荐答案
我用这段代码解决了这个问题
I solve that problem by using this code
btnAddField.fireEvent(new ButtonClickEvent ())
private class ButtonClickEvent extends ClickEvent{
/*To call click() function for Programmatic equivalent of the user clicking the button.*/
}
现在一切正常.
这篇关于在 GWT 中以编程方式调用 click() 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文