Vertical Axis of WebCanvas Inside Container?

  1. 2 months ago
    Edited 2 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.

    @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

    Apr 9 Xojo Inc

    The top coordinate of the canvas is already zero.

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

  3. Edited 2 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. @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

    Apr 9 Xojo Inc

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

  6. WebCanvas mousedown.

  7. Greg O

    Apr 9 Xojo Inc

    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

    Apr 9 Xojo Inc

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

  9. @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. Edited 2 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

    Apr 10 Xojo Inc

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

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

    Thanks for your help Greg.

  13. @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?

  14. Greg O

    Apr 13 Xojo Inc

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

  15. Geoff H

    Apr 18 Answer USA
    Edited 2 months ago

    @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))

or Sign Up to reply!