Vaadin中的ENTER快捷键和TextArea [英] Both ENTER shortcut and TextArea in Vaadin

查看:120
本文介绍了Vaadin中的ENTER快捷键和TextArea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TextField f = new TextField();
Button b = new Button("Save");
b.setClickShortcut(KeyCode.ENTER); // For quick saving from text field itself

TextArea longText = new TextArea(); // "Enter" is garbled here

是否要使快捷方式仅在发件人"文本字段中起作用?

Hot to make the shortcut to work only in the from text field?

推荐答案

使用焦点和模糊侦听器删除并添加快捷键:

Use focus and blur listeners to remove and add the shortcut key:

    f.addFocusListener(new FocusListener() {
        @Override
        public void focus(FocusEvent event) {
            b.setClickShortcut(KeyCode.ENTER);
        }
    });
    f.addBlurListener(new BlurListener() {
        @Override
        public void blur(BlurEvent event) {
            b.removeClickShortcut();
        }
    });

这篇关于Vaadin中的ENTER快捷键和TextArea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆