我已使用preventDefault停止了一个事件。现在我想重新抛出它。我尝试了fireEvent但是没有用。有没有办法实现这个目标?
UPDATE 我创建了一个新的事件实例并使用了elem.dispatchEvent(clickEvent),而不是fire事件;
Event.addNativePreviewHandler(new Event.NativePreviewHandler()
{
public void onPreviewNativeEvent(NativePreviewEvent event)
{
if (event.getTypeInt() == Event.ONMOUSEDOWN)
{
Element elem = JSHelper.elementFromPoint(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
EventListener listener = Event.getEventListener(elem);
if((listener instanceof ListBox))
{
event.getNativeEvent().preventDefault();
//// ((ListBox) listener).fireEvent(event);
int y = event.getNativeEvent().getClientY();
int x = event.getNativeEvent().getClientX();
int screenX = event.getNativeEvent().getScreenX();
int screenY = event.getNativeEvent().getScreenY();
NativeEvent clickEvent = Document.get().createMouseEvent(
"click",true, false,0, screenX, screenY, x, y, false, false,
false, false, NativeEvent.BUTTON_LEFT, elem);
elem.dispatchEvent(clickEvent);
}
}
}
});
答案 0 :(得分:0)
你为什么要再次开火呢?试着调用你想要的事件处理函数