Friday, September 10, 2010

How to intercept ONPASTE events

In order to modify what gets pasted to my application, I'm attempting
to intercept ONPASTE events as described by Jim Douglas in this
thread:

http://groups.google.com/group/google-web-toolkit/browse_thread/thread/09a3527707d22be0?fwc=1

The problem is that I'm never seeing the ONPASTE event occur. I've
tried firefox and safari.

I'm able to see MOUSEDOWN detected and I get "BROWSER EVENT DETECTED"
whenever I move the mouse over the RichTextAreaWithPaste (see code
below), but whether I use Control-V (or Command-V on the Mac) or the
context menu for pasting, I never see "PASTE DETECTED".

I'm wondering if anyone has any clues that might help?

Thanks,

--Jim Dempsey--


Here's my subclass of RichTextArea:

package com.whatever.client;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.RichTextArea;

public class RichTextAreaWithPaste extends RichTextArea {

public RichTextAreaWithPaste() {
super();
sinkEvents(Event.ONPASTE);
sinkEvents(Event.ONMOUSEDOWN);

}

@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
log("BROWSER EVENT DETECTED");
switch (event.getTypeInt()) {
case Event.ONPASTE:
log("PASTE DETECTED");
break;
case Event.ONMOUSEDOWN:
log("MOUSEDOWN DETECTED");
}
}
}

--
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