Monday, January 31, 2011

Re: Firefox ONPASTE: Get the text to be pasted?

Thanks for posting this!  Very helpful!  I did variation on the theme. 

I created a class called XTextBox (and XTextArea) which catches the ONPASTE and then fires the ValueChangedEvent. This is useful because all I need to do is call the textBox.addValueChangeHandler(aHandler)  in my presenter class. 

public class XTextBox extends TextBox  {

    public XTextBox() {
        super();
       
        this.sinkEvents(Event.ONPASTE);
    }
   
   
    /**
     * Catch ONPASTE and re-throw it as a ValueChangeEvent
     *
     */
   
    @Override
    public void onBrowserEvent(Event event) {
        super.onBrowserEvent(event);
        switch (event.getTypeInt()) {
            case Event.ONPASTE: {
                String newValue = null;  // get the pasted value here!!!
                this.setValue(newValue, true);
                break;
            }
        }
    }

}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment