【问题标题】:Read the text on ONPaste Event in gwt阅读 gwt 中关于 ONPaste 事件的文本
【发布时间】:2016-02-16 04:47:13
【问题描述】:

我在获取关于 ONPASTE 事件的文本时遇到问题。假设我有 5 个文本框,并且我正在使用 sinkEvent,那么我将如何获取要粘贴到任何文本框中的文本

public abc() {
    super();
    TextBox t1 = new TextBox();
    TextBox t2 = new TextBox();
    TextBox t3 = new TextBox();
    TextBox t4 = new TextBox();
    TextBox t5 = new TextBox();

    sinkEvents( Event.ONPASTE );
}

@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent( event );

    switch (DOM.eventGetType(event)) {
        case Event.ONPASTE:
            //Now here i want to read get the text which is going to be 
            //pasted in the any of the textbox
    }
}

【问题讨论】:

    标签: java gwt onpaste


    【解决方案1】:

    您必须在文本框本身中捕捉事件。您可以扩展文本框以在 onpaste 事件上触发事件,或者像这样快速而肮脏地进行操作:

    public abc() {
        super();
        TextBox t1 = new TextBox(){
    
            @Override
            public void onBrowserEvent(Event event) {
                super.onBrowserEvent(event);
                checkForPastEventAndDoSomething(event);
            }
        };
        //...
    }
    
    private void checkForPastEventAndDoSomething(Event event) {
        switch (event.getTypeInt()) {
                    case Event.ONPASTE:
                    //Now here i want to read get the text which is going to be 
                    //pasted in the any of the textbox
                    break;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 2011-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多