4

I have a GWT container with some stuff in it and an image which is added a clickhandler.

What I try to do is to get the exact mouse event's X and Y coordinates relative to the image. I saw the post here but this is not what I want.

As far as I can see, I have option like getting the image absolute location and event location but this works only if the user doesn't scroll down the page.

event.getNativeEvent().getClientY()- image.getElement().getAbsoluteTop();
2
  • 1
    I don't know much about gwt, but if the above methods exist, there should be a function to get the scrollX and scrollY just like in javascript. Then you would combine all of the above to be event.getNativeEvent().getClientY()-image.getElement().getAbsoluteTop()-(document.scrollTop?)
    – Samuel
    Dec 5, 2009 at 18:18
  • yeap, this is the thing I am looking for, and this is the code for it event.getNativeEvent().getClientY()- image.getAbsoluteTop() + Document.get().getScrollTop() thanks for the very useful insight Dec 5, 2009 at 19:39

1 Answer 1

1

Thanks to Samuel,

here is the solution

event.getNativeEvent().getClientY()- image.getAbsoluteTop() + Document.get().getScrollTop()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.