简体   繁体   English

GWT TextArea 事件侦听器

[英]GWT TextArea Event Listener

I am going to try to add a listener but i don't know what to do.我将尝试添加一个侦听器,但我不知道该怎么做。

I want to execute a function after the user finish inputting text.我想在用户完成输入文本后执行一个函数。

For example, a user input text "123" in to my TextArea and use mouse to click outside , or click another field / whatever.例如,用户在我的 TextArea 中输入文本“123”并使用鼠标单击外部,或单击另一个字段/任何内容。

What listen should i use in GWT?我应该在 GWT 中使用什么监听?

I don't know the keywords of the listener so i come here for help.我不知道听众的关键词所以我来这里寻求帮助。

The Code i had try it simply, actually i don't think it helps a lot if i provide the coding since i only don't know what listener / how to make the function i want.我简单地尝试过的代码,实际上我认为如果我提供编码并没有太大帮助,因为我只是不知道什么侦听器/如何制作我想要的功能。

private TextArea TextAreaPartA;
TextAreaPartA = new TextArea();
TextAreaPartA.setFieldLabel("PartA");
TextAreaPartA.setSize(500, 40);
//TextAreaPartA.onComponentEvent(ce);

You can try addBlurHandler你可以试试addBlurHandler

TextAreaPartA.addBlurHandler(new BlurHandler()
{
            @Override
            public void onBlur(BlurEvent event)
            {
                         //do stuff
            }
});

Use AddBlurHandler,使用 AddBlurHandler,

TextArea area=new TextArea;    
 area.addBlurHandler(new BlurHandler() {
            @Override
            public void onBlur(final BlurEvent event) {
                // Do the Stuff here
            }
        });

addBlurHandler() does not work because it seems like you are not using the actual GWT TextArea (I think you use the TextArea from GwtExt). addBlurHandler()不起作用,因为您似乎没有使用实际的 GWT TextArea(我认为您使用的是 GwtExt 中的 TextArea)。 Please check your import, it should be import com.google.gwt.user.client.ui.TextArea;请检查您的导入,它应该是import com.google.gwt.user.client.ui.TextArea;

Please also note that you should start variable names lowercase.另请注意,变量名称应以小写开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM