使用GWT阅读剪贴板数据 [英] Read clipboard data with GWT

查看:109
本文介绍了使用GWT阅读剪贴板数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码来处理来自浏览器的 CTRL + V ,但工作正常我需要这样的剪贴板数据:

  Event.addNativePreviewHandler(new Event.NativePreviewHandler(){
@覆盖
public void onPreviewNativeEvent(Event.NativePreviewEvent event)
{
NativeEvent ne = event.getNativeEvent();
//按下CTRL + V
if( event.getNativeEvent()。getKeyCode()== 86&& amp; //'V'
event.getNativeEvent()。getCtrlKey()== true){
//需要获取剪贴板数据
}
}
});


解决方案

虽然我是将此问题标记为一个重复的,我想这个问题的答案可能有点过时了。当我谷歌,我发现这个讨论。在那里的答案解决了JSNI的问题,但他们表示它在FF中不起作用,因为FF需要手动启用限制。如果这不起作用,您可能需要在副本中使用答案。

I have this code that I have made to handle the CTRL+V from the browser, works fine however I need to get the clipboard data like this:

    Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(Event.NativePreviewEvent event)
        {
            NativeEvent ne = event.getNativeEvent();
            // When CTRL + V is pressed
            if (event.getNativeEvent().getKeyCode() == 86 && // 'V'
                    event.getNativeEvent().getCtrlKey() == true) {
                // need to get the clipboard data
            }
        }
    });

解决方案

Although I'm the one that marked this question as a duplicate, I think the answers in that question may be bit out of date. When I google, I find this discussion. The answers in there solve the problem with JSNI but they remark that it doesn't work in FF because FF requires manually enabling restrictions. If this doesn't help, you may have to use the answers in the duplicate.

这篇关于使用GWT阅读剪贴板数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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