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();
Community
  • 1
  • 1
Robert Childan
  • 983
  • 1
  • 12
  • 22
  • 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 05 '09 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 – Robert Childan Dec 05 '09 at 19:39

1 Answers1

1

Thanks to Samuel,

here is the solution

event.getNativeEvent().getClientY()- image.getAbsoluteTop() + Document.get().getScrollTop()
Robert Childan
  • 983
  • 1
  • 12
  • 22