eclipse 我可以检测 SWT 中文本字段的变化吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11653247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:40:16  来源:igfitidea点击:

Can I detect change in text fields in SWT?

javaeclipseswt

提问by noMAD

I have a couple of SWT widgets. I am trying to create an action if there is any modification in any of the fields present.

我有几个 SWT 小部件。如果存在的任何字段有任何修改,我将尝试创建一个操作。

Example: If I change the name from the TextI should be able to identify it. I tried searching online for a solution but couldn't find a suitable one.

示例:如果我更改名称,Text我应该能够识别它。我尝试在网上搜索解决方案,但找不到合适的解决方案。

Any suggestions?

有什么建议?

回答by Baldrick

Use addModifyListener

使用addModifyListener

ModifyListener listener = new ModifyListener() {
    /** {@inheritDoc} */
    public void modifyText(ModifyEvent e) {
        // Handle event
    }
});

text1.addModifyListener(listener);
text2.addModifyListener(listener);