gpt4 book ai didi

java - GWT TextArea onBlur 未被调用

转载 作者:行者123 更新时间:2023-12-01 08:47:39 25 4
gpt4 key购买 nike

我在 GWT 中有一个 TextArea 类,我已经扩展了它,但是我的事件处理方法似乎都没有被调用。我已经像这样定义了我的类:

private class MTextBox extends TextArea {
public MTextBox() {
super();
this.addDomHandler(new BlurHandler(){
@Override
public void onBlur(BlurEvent event) {
//Handle Blur
}
}, BlurEvent.getType());
this.addDomHandler(new FocusHandler(){
@Override
public void onFocus(FocusEvent event) {
// Handle Focus.
}
}, FocusEvent.getType());
}

最佳答案

对我来说似乎很好,事件被正确触发:

import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.goulds.client.views.ApplicationEntryPoint;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestMTextBox extends ApplicationEntryPoint
{
private class MTextBox extends TextArea {
public MTextBox() {
super();
this.addDomHandler(new BlurHandler(){
@Override
public void onBlur(BlurEvent event) {
//Handle Blur
GWT.log("onBlur");
}
}, BlurEvent.getType());
this.addDomHandler(new FocusHandler(){
@Override
public void onFocus(FocusEvent event) {
// Handle Focus.
GWT.log("onFocus");
}
}, FocusEvent.getType());
}
}



@Override
public void onModuleLoad()
{
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.add(new MTextBox());
verticalPanel.add(new MTextBox());
verticalPanel.add(new MTextBox());


RootPanel.get().add(verticalPanel);
}
}

关于java - GWT TextArea onBlur 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42576211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com