将事件粘贴到GWT上 [英] Paste event on GWT

查看:113
本文介绍了将事件粘贴到GWT上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个如何在GWT上的TextArea上捕获Paste事件的例子,但它不起作用。

  public MyTextArea(){
super();
sinkEvents(Event.ONPASTE);
}

@Override
public void onBrowserEvent(Event event){
super.onBrowserEvent(event);
switch(event.getTypeInt()){
case Event.ONPASTE:
System.out.println(Paste Pastected);
Window.alert(Paste Works !!! Yippie !!!);
休息;




$ b $ p
$ b

问题是我从来没有进入onBrowserEvent ..任何建议?
Thnx

解决方案



 public class Starter implements EntryPoint {
$ b $ @Override
public void onModuleLoad(){
RootPanel.get()。add(new MyTextArea ());
}

class MyTextArea extends TextArea {
public MyTextArea(){
super();
sinkEvents(Event.ONPASTE);
}

@Override
public void onBrowserEvent(Event event){
super.onBrowserEvent(event);
switch(event.getTypeInt()){
case Event.ONPASTE:
System.out.println(Paste Pastected);
Window.alert(Paste Works !!! Yippie !!!);
休息;
}
}
}
}

开你在测试什么浏览器?

I found an example of how to catch the Paste event on a TextArea on GWT but it doesn't work.

public MyTextArea() {
    super();
    sinkEvents(Event.ONPASTE);
}

@Override 
public void onBrowserEvent(Event event) { 
    super.onBrowserEvent(event); 
    switch (event.getTypeInt()) { 
    case Event.ONPASTE: 
        System.out.println("Paste Detected"); 
        Window.alert("Paste Works!!! Yippie!!!");
        break; 
    } 
} 

The problem is that I never enter to onBrowserEvent ... Any suggestion ? Thnx

解决方案

Works for me as intended:

public class Starter implements EntryPoint {

    @Override
    public void onModuleLoad() {
        RootPanel.get().add(new MyTextArea());
    }

    class MyTextArea extends TextArea {
        public MyTextArea() {
            super();
            sinkEvents(Event.ONPASTE);
        }

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            switch (event.getTypeInt()) {
            case Event.ONPASTE:
                System.out.println("Paste Detected");
                Window.alert("Paste Works!!! Yippie!!!");
                break;
            }
        }
    }
}

On what browser are you testing it?

这篇关于将事件粘贴到GWT上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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