View Full Version : How to get position of element in Panel relative to page?

18 Nov 2009, 10:48 AM
I have a Panel with a Button in it located at x: 50 and y: 50. If I have the Panel set to autoScroll = true and I resize the Panel over the Button, causing the scrollbars to appear, and I scroll all the way to the right, is there a way to get the position of the Button relative to the page (browser window), rather than just relative to the Panel, which will still report 50x50? So I guess somehow it would have to account for the scroll offset or something, for example, if I happen to scroll over by 20px, it should return x: 30, not 50. Any help would be appreciated.

18 Nov 2009, 11:55 AM
I would think if you capture the size of the panel first off then after resize get the new size that will give you the offset number.

Panel before resize: x = 100
Panel after resize: x=120

button x= 50
xoffset = 20

so a touch of x=30 would hit the button.

I see where your going with this on a touchscreen solution. But not sure why you would need it as when you touch the screen and let go that equals a mouse click which will filter down to the button anyways with out you having to calculate anything.

My touchscreen app works with no recalc of where the button is.


18 Nov 2009, 12:47 PM
Nothing to do with a touchscreen app. But what you have suggested here, I don't think will work. I'm not necessarily resizing the panel, it was just used a test case to illustrate my question. My question is more to do with, when then container has been scrolled to any position, how do I get the offset of that scroll, so that I can do something with that.

Anyone know how to get the amount the container element has been scrolled either vertically, or horizontally?