similar case: import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event;
..... protected CellList contactList; .... contactList.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent evt) { evt.preventDefault(); final NativeEvent event = evt.getNativeEvent(); final NativeEvent newEvent = Document.get().createClickEvent(-1, event.getScreenX(), event.getScreenY(), event.getClientX(), event.getClientY(), event.getCtrlKey(), event.getAltKey(), event.getShiftKey(), event.getMetaKey()); DOM.eventGetTarget(Event.as(event)).dispatchEvent(newEvent); } }, ContextMenuEvent.getType()); ... But : contactList.getElement().dispatchEvent(newEvent); instead of : DOM.eventGetTarget(Event.as(event)).dispatchEvent(newEvent); - not working... So, i think, you correctly create native event, but you send them to incorrect target. пятница, 31 мая 2013 г., 12:04:10 UTC+6 пользователь Chris написал: > > Hello, > I am interested in using GWTTestCase to test some features of a view that > extends CellTable. In my implementation, I have added a CellPreviewHandler > that I would like to check by firing a click event on a cell of the > CellTable. I have tried several methods to no avail. > > My most recent attempt follows: > > CellTable<Artist> cellTable = (CellTable<Artist>) view.getDataView(); > NativeEvent event = Document.get().createClickEvent(0, 0, 0, 20, 30, > false, false, false, false); > DomEvent.fireNativeEvent(event, cellTable); > > This does not work. The CellPreviewHandler doesn't get called. > > This has also been tried: > > CellTable<Artist> cellTable = (CellTable<Artist>) view.getDataView(); > NativeEvent event = Document.get().createClickEvent(0, 0, 0, 0, 0, false, > false, false, false); > TableCellElement element = > cellTable.getRowElement(2).getCells().getItem(1); > element.dispatchEvent(event); > > Same problem as the former. > > *TL;DR* > Does anyone have insight as to how I can simulate a click event that will > fire a CellPreviewEvent on a CellTable for a desired Cell? > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/groups/opt_out.