我遇到了在ONPASTE事件上获取文本的问题。假设我有5个文本框,并且我使用的是sinkEvent,那么我如何获得要粘贴到任何一个文本框中的文本呢
public abc() {
super();
TextBox t1 = new TextBox();
TextBox t2 = new TextBox();
TextBox t3 = new TextBox();
TextBox t4 = new TextBox();
TextBox t5 = new TextBox();
sinkEvents( Event.ONPASTE );
}
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent( event );
switch (DOM.eventGetType(event)) {
case Event.ONPASTE:
//Now here i want to read get the text which is going to be
//pasted in the any of the textbox
}
}发布于 2016-02-16 19:33:21
您必须在textbox本身中捕获事件。您可以扩展textbox以在onpaste事件上触发事件,或者像这样快速而肮脏地执行此操作:
public abc() {
super();
TextBox t1 = new TextBox(){
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
checkForPastEventAndDoSomething(event);
}
};
//...
}
private void checkForPastEventAndDoSomething(Event event) {
switch (event.getTypeInt()) {
case Event.ONPASTE:
//Now here i want to read get the text which is going to be
//pasted in the any of the textbox
break;
}https://stackoverflow.com/questions/35423970
复制相似问题