问题
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();
回答1:
Thanks to Samuel,
here is the solution
event.getNativeEvent().getClientY()- image.getAbsoluteTop() + Document.get().getScrollTop()
来源:https://stackoverflow.com/questions/1852921/mouse-click-location-on-an-image