479 views

# Vertical Axis of WebCanvas Inside Container?

1. 10 months ago

### Geoff H

9 Apr 2019 USA
Edited 10 months ago

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.

See post in context

@Greg OLone

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. :)

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))```
2. ### Greg O

9 Apr 2019 Xojo Inc scout.galaxy.barn

The top coordinate of the canvas is already zero.

3. ### Geoff H

9 Apr 2019 USA
Edited 10 months ago

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.

4. ### Geoff H

9 Apr 2019 USA

@Greg OLone

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?

5. ### Greg O

9 Apr 2019 Xojo Inc scout.galaxy.barn

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

6. ### Geoff H

9 Apr 2019 USA

WebCanvas mousedown.

7. ### Greg O

9 Apr 2019 Xojo Inc scout.galaxy.barn

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?

8. ### Greg O

9 Apr 2019 Xojo Inc scout.galaxy.barn

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

9. ### Geoff H

9 Apr 2019 USA

@Greg OLone 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?

Yes I can do that.

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

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

10. ### Geoff H

10 Apr 2019 USA
Edited 10 months ago

@Greg OLone

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... :(

11. ### Greg O

10 Apr 2019 Xojo Inc scout.galaxy.barn

@Geoff H - 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?

10 Apr 2019
13. ### Geoff H

10 Apr 2019 USA

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

14. 9 months ago

### Geoff H

13 Apr 2019 USA

@Greg OLone 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?

@Greg OLone 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?

15. ### Greg O

13 Apr 2019 Xojo Inc scout.galaxy.barn

@Geoff H @Greg OLone 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...

Could you put together a sample and file a bug report in Feedback so I can look at it?

16. ### Geoff H

```Dim surf As RGBSurface = pColorPicker.RGBSurface