How to intercept ONPASTE events

106 views
Skip to first unread message

jjd

unread,
Sep 10, 2010, 12:11:19 PM9/10/10
to Google Web Toolkit
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");
}
}
}
Reply all
Reply to author
Forward
0 new messages