Search code examples
gwtcopy-paste

GWT pasting event


I want to handle events when user pastes some text in TextBox. Which event is fired in this situation? I tried ValueChange and Change handlers, but they didn't work.


Solution

  • This might help you. Describes a workaround to hook to the onpaste event. In short:

    • subclass TextBox

    • sink the onpaste event in the constructor

      sinkEvents(Event.ONPASTE);
    • override onBrowserEvent(Event event)

      public void onBrowserEvent(Event event) {
          super.onBrowserEvent(event);
          switch (event.getTypeInt()) {
              case Event.ONPASTE: {
                  // do something here
                  break;
              }
          }
      }