That's really strange that you couldn't add a widget to the DOM within the preview event handler - I can't think of a reason why it would prevent you from doing that. I agree - it's really hard to find an actual definitive reference guide for the DOM model & what kind of stuff you are & aren't allowed to do.
MDC <https://developer.mozilla.org/En> has some good info & examples, but it's fairly Firefox specific (it'll usually be correct for other browsers, but it'll be annoying when it's not). On Wed, Apr 29, 2009 at 10:47 AM, Gavin Andresen <[email protected]>wrote: > > For anybody trying to do something similar, my working code (using > event.preventDefault, and using DeferredCommand did the trick): > > // > // Preview events-- look for shift-clicks on paper/author links, and > pops up > // edit dialog boxes: > // > public void onPreviewNativeEvent(Event.NativePreviewEvent pe) { > NativeEvent e = pe.getNativeEvent(); > if (Event.getTypeInt(e.getType()) != Event.ONCLICK) { return; } > if (!e.getShiftKey()) { return; } > > EventTarget target = e.getEventTarget(); > if (!Element.is(target)) { return; } > Element elt = Element.as(target); > String href = elt.getAttribute("href"); > if (href == null || href.length() == 0){ return; } > > if (href.contains("/paper/")) { > e.preventDefault(); > final String paperPID = InterfaceUtils.getPIDFromLinkString > (href, "paper/"); > DeferredCommand.addCommand(new Command() { > public void execute() { fetchPaperInfoThenEdit(paperPID); } > }); > > } > else if (href.contains("/author/")) { > e.preventDefault(); > final String authorPID = InterfaceUtils.getPIDFromLinkString > (href, "author/"); > Map<String,String> params = InterfaceUtils.parseURLParams(href); > final String fromPaperPID = params.get("fromPaper"); > DeferredCommand.addCommand(new Command() { > public void execute() { fetchAuthorInfoThenEdit(authorPID, > fromPaperPID); } > }); > } > } > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
