Vertical Axis of WebCanvas Inside Container?

I have a WebCanvas in a container. I am trying to work out the proper calculation to set the vertical Y coordinate to 0 at the top of the canvas on mousedown to work like a desktop canvas. Thanks for any help.

The top coordinate of the canvas is already zero.

Can you give a little more info about what you are trying to accomplish?

The X coordinate is 0 but the Y coordinate appears to be a different calculation. When I mousedown at the top left corner of the WebCanvas I get 0 for X and -815 for y. For the WebCanvas top I get 899. If I scroll the WebCanvas to the very top of the screen the top left Y coordinate is -899 on mousedown.

The WebCanvas height is 150. I want to calculate the top left Y coordinate to 0 and bottom left y coordinate to be the total height of the WebCanvas on mousedown.

@Greg O’Lone

After further investigation I have found this issue I am facing is caused by having the WebCanvas inside of a container that is placed on the WebPage.

If I add the WebCanvas to the page outside of the container it is as you said top left Y coordinate is 0.

Any thoughts on how to calculate this Y coordinate for a WebCanvas inside of a container?

Which control & event are you using to get the y coordinate from?

WebCanvas mousedown.

Huh… well that shouldn’t be. Could you put together a sample and file a bug report in Feedback so I can look at it?

Are you by any chance putting that canvas inside of a container such that it can be scrolled vertically?

Yes I can do that.

The Container itself is set to Scrollbars Visible Automatic and the height is large enough that the WebPage has a scrollbar.

@Greg O’Lone

I got the Y coordinate finally by scrolling the canvas to the top of the container where I could predict the canvas.top by using container.top.

But now the MouseUp event is not firing for the WebCanvas… :frowning:

@Geoff Haynes - Could you give me an idea of what you are trying to do with the WebCanvas? Just in case there’s a better way to approach this?

Nevermind for some reason mouseup is working now after I removed and re-added the container to the web page. :confused:

Thanks for your help Greg.

@Greg O’Lone Should I still file that bug report or did you conclude that the issue I was facing for a WebCanvas inside of a container was due to the container being scrolled vertically?

Regardless…

@Greg O’Lone

The ContentScrolled event was the answer I was looking for. By converting the negative Y axis value of the WebCanvas to a positive value and subtracting it from the value for the Y axis from ContentScrolled I can always find the 0 y value for the top left corner of the WebCanvas inside of a scrollable container. :slight_smile:

In WebCanvas MouseDown.

Dim surf As RGBSurface = pColorPicker.RGBSurface
txtBackColor.Text = "#" + str(surf.pixel(x, intScrollY - ABS(y))).right(6) 
cPick = surf.pixel(x, intScrollY - ABS(y))