0

I am facing problem to get text on ONPASTE event. Suppose i have 5 textboxes and i am using sinkEvent then how would i get the text which going to be pasted in any of the textbox

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
    }
}
N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46
Kushal Jain
  • 3,029
  • 5
  • 31
  • 48

1 Answers1

1

you have to catch the event in the textbox itself. you could extend the textbox to fire an event on onpaste event or do it quick and dirty like this:

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;
}
Tobika
  • 1,037
  • 1
  • 9
  • 18