开发者

Mouse click location on an image

开发者 https://www.devze.com 2022-12-13 03:38 出处:网络
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

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 locat开发者_JAVA百科ion but this works only if the user doesn't scroll down the page.

event.getNativeEvent().getClientY()- image.getElement().getAbsoluteTop();


Thanks to Samuel,

here is the solution

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

精彩评论

暂无评论...
验证码 换一张
取 消