3

I have two textboxes and i want to just disable one of them from pasting anything. I have tried

 sinkEvents( Event.ONPASTE ); 

but it disables both of the textboxes from pasting.

Pradip Borde
  • 2,516
  • 4
  • 18
  • 20

1 Answers1

4

Try to create a custom TextBox wherein you have to override onBrowserEvent function.

public TextInput() {
    super();

    sinkEvents( Event.ONPASTE );
}

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

    switch (DOM.eventGetType(event)) {
        case Event.ONPASTE:
            event.preventDefault();
            break;
    }
}
vvns
  • 3,548
  • 3
  • 41
  • 57