DialogBox 标题栏中 GWT 自定义按钮中的 onclick 事件
Onclick event in GWT custom button in title bar of DialogBox
我需要在对话框的标题栏中添加打开某些文档的按钮;
我的帮助按钮 class 看起来像这样:
public class HelpButtonSmall extends Button {
public HelpButtonSmall(final String name) {
super();
setHTML("<input type=\"image\" src=\"/img/ico-help-sm.png\" name=\"image\">");
addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("Help");
}
});
}
}
在我的对话框中,我在标题栏中添加按钮,如下所示:
HTML caption = ((HTML)this.getCaption());
HelpButtonSmall smallButton = new HelpButtonSmall("Show help alert");
caption.getElement().appendChild(smallButton.getElement());
问题是点击按钮后不显示警告消息。
请帮我解决这个问题。
当使用 getElement()
时,您将返回 DOM 元素的本机处理程序,这样做会丢失作为 Widget 完成的任何逻辑,包括 addClickHandler
。
如果目的是添加关闭按钮,还有其他方法可以实现。这是 theme.
之一
我需要在对话框的标题栏中添加打开某些文档的按钮;
我的帮助按钮 class 看起来像这样:
public class HelpButtonSmall extends Button {
public HelpButtonSmall(final String name) {
super();
setHTML("<input type=\"image\" src=\"/img/ico-help-sm.png\" name=\"image\">");
addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("Help");
}
});
}
}
在我的对话框中,我在标题栏中添加按钮,如下所示:
HTML caption = ((HTML)this.getCaption());
HelpButtonSmall smallButton = new HelpButtonSmall("Show help alert");
caption.getElement().appendChild(smallButton.getElement());
问题是点击按钮后不显示警告消息。
请帮我解决这个问题。
当使用 getElement()
时,您将返回 DOM 元素的本机处理程序,这样做会丢失作为 Widget 完成的任何逻辑,包括 addClickHandler
。
如果目的是添加关闭按钮,还有其他方法可以实现。这是 theme.
之一