I tried that code and that actuall activates every time something is clicked. I only want to get the "A" tags so what I had before works a little better. but thanks for turning me on to the anchorElement.
On Sep 2, 5:23 am, Thomas Broyer <[email protected]> wrote: > On 2 sep, 04:26, Chris Bailey <[email protected]> wrote: > > > > > > > OK here is the soluction I came up with: > > > Event.addNativePreviewHandler(new Event.NativePreviewHandler() { > > @Override > > public void onPreviewNativeEvent(NativePreviewEvent > > event) { > > if (event.getTypeInt() == Event.ONCLICK) { > > > // do something with the keycode > > // > > doSomething(event.getNativeEvent().getKeyCode()); > > > > > if(com.google.gwt.dom.client.Element.is(event.getNativeEvent > > ().getEventTarget())){ > > Element targetElement = > > (Element) Element.as(event.getNativeEvent > > ().getEventTarget()); > > > > if("a".equalsIgnoreCase(getTagName(targetElement))) { > > //String hostURL = > > GWT.getHostPageBaseURL(); > > > String href = > > DOM.getElementAttribute > > ((com.google.gwt.user.client.Element) targetElement, "href"); > > How about: > EventTarget eventTarget = event.getNativeEvent().getEventTarget(); > if (AnchorElement.is(eventTarget)) { > AnchorElement targetElement = eventTarget.cast(); > String href = targetElement.getHref(); > ... > > I'd also wrap the whole thing within an if (!event.isCancelled()) > { ... } > > > check href against hostURL to see if the link is realitive or absolute > > then do whatever you want. > > Oh, so you meant "relative"! I thought you meant something related to > "real" (like, links to something "real", i.e. make a request and see > if it returns an error)- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
