Is it possible to react on the user pasting text into a GWT textbox?
(Both using STRG+V and using the right-mouse context menu Paste).
ValueChange, MouseUp, ... are not fired, as I had expected them to
do. :(
Any ideas?
Thanks in Advance for your help!
Stefan
You'll need to subclass TextBox, then do this:
(1) Add this to the constructor:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/UIObject.html#sinkEvents(int)
http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/Event.html#ONPASTE
sinkEvents(Event.ONPASTE);
(2) Override this method:
@Override
public void onBrowserEvent(Event event)
{
super.onBrowserEvent(event);
switch (event.getTypeInt())
{
case Event.ONPASTE:
{
// do something here
break;
}
}
}
N.B.:
(1) Opera doesn't fire any cut, copy or paste events, so this won't
work in Opera.
(2) If you want to find the text that the user is about to paste and
do something special with it, this will only be possible in IE or
WebKit-based browsers (Safari & Chrome).