Hi, 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.
views:
53answers:
2
+1
A:
GWT does not yet have support for cut, copy & paste: http://code.google.com/p/google-web-toolkit/issues/detail?id=4030
Edited: Another option is to use JSNI. For example add this to your GWT class:
public native void addCutHandler(Element elementID)
/*-{
var temp = this; // hack to hold on to 'this' reference
elementID.oncut = function(e) {
[email protected]::handleCut()();
}
}-*/;
public void handleCut() {
Window.alert("Cut!");
}
Peter Knego
2010-10-25 19:55:49
A:
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; } } }
z00bs
2010-10-25 20:24:51