Webgraphics drives me nuts! Bug?

  1. 3 weeks ago

    Markus W

    May 1 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...
    Edited 3 weeks ago

    I'm using the simple webgraphics boxes example with Xojo 2019R3 on my Mac which works fine.

    I modifiy the code and it works fine:

    Sub Paint(g as WebGraphics) Handles Paint
      
      g.ClearRect(0, 0, g.Width, g.Height)
       
      g.ForeColor = &cff0000
      g.TextFont = "Helvetica"
      g.TextSize = 16
      
      g.DrawString("Hello world!", 10, 130)
      
    End Sub

    I add a TextArea with some text and change the code to

    Sub Paint(g as WebGraphics) Handles Paint
      
      g.ClearRect(0, 0, g.Width, g.Height)
       
      g.ForeColor = &cff0000
      g.TextFont = "Helvetica"
      g.TextSize = 16
      g.DrawString(TextArea1.Text, 50, 130)
      
      g.DrawString("Hello world!", 10, 130)
      
    End Sub

    and nothing is shown on the webcanvas, not even the "Hello World!".

    I comment out the g.DrawString(TextArea1.Text, 50, 130) line and it paints the "Hello World!" just fine.

    I can have two .DrawString lines just fine:

    g.DrawString("Hello world!", 10, 130)
    g.DrawString("Jurassic world!", 10, 160)

    Where am I going wrong?

  2. Greg O

    May 2 Xojo Inc

    What text is in the text area? I know it shouldn’t matter, but let’s narrow this down first.

  3. Richard D

    May 2 Pre-Release Testers, Xojo Pro Europe (UK, London)

    @Markus W 2019R3

  4. Wayne G

    May 2 Pre-Release Testers, Xojo Pro New Zealand axisdirect.nz

    I would suggest

    Dim s As String = TextArea1.text
    g.DrawString(s, 50, 150)

    and see how that works. What is the encoding for s?

    BTW where can I find 2019R3? Is Android available?

  5. Markus W

    May 2 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    @Greg OLone What text is in the text area? I know it shouldn’t matter, but let’s narrow this down first.

    Just some random text that I typed in.

  6. Markus W

    May 2 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    @Wayne G I would suggest

    Dim s As String = TextArea1.text
    g.DrawString(s, 50, 150)

    and see how that works. What is the encoding for s?

    Had already tried that. All internal Xojo strings are UTF8. There are no non-ASCII characters in my text, just some random letters like “kgrdfcvh”

  7. Markus W

    May 2 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    @Richard D

    Would be nice, but alas, I’m not a time traveller (but then I would say that, wouldn’t I?) …

  8. Greg O

    May 2 Xojo Inc

    @Markus W Just some random text that I typed in.

    ok, so in the browser you're running on, open the developer console and run your app again. My suspicion is that there's a javascript error of some kind happening when you draw the string, and I was hoping it was going to be something as simple as an encoding issue or a wayward apostrophe or quote that was causing the issue.

    Anyway, if it is a Javascript error in the graphics code translation and we can track it down we can probably figure out what's going on.

  9. Greg O

    May 2 Xojo Inc

    Oh, and have you tried turning off the Diff Engine for that canvas?

  10. Markus W

    May 2 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    Ok, found the problem. If the TextArea has an EndOfLine in it (I usually press the return at the end of a line) then it will prevent all drawing.

    So the following code works fine

    g.DrawString("Hello world!", 10, 130)
    g.DrawString("Jurassic world!", 10, 160)

    but this one results in an empty canvas:

    g.DrawString("Hello world!", 10, 130)
    g.DrawString("Jurassic world!" + EndOfLine, 10, 160)

    The same if I add an EndOfLine.Unix.

    If I add an EndOfLine.Macintosh or EndOfLine.Windows I get a crash:

    Could not execute returned javascript: Unexpected EOF
    Source: try {
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.clearRect(0,0,1147,748);',23);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.clearRect(0,0,1147,748);',24);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.font = \'16px Helvetica\';',25);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.fillStyle = \'rgba(255,0,0,1.0)\';',26);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.fillText(\'Hello world!\',10,130);',27);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.font = \'16px Helvetica\';',28);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.fillStyle = \'rgba(255,0,0,1.0)\';',29);
    Xojo.controls['m7eEZ2sZ'].editScript(1,'context.fillText(\'Jurassic world!
    \',10,160);',30);
    Xojo.controls['m7eEZ2sZ'].runScript(2);
    } catch(ex) { }

  11. Markus W

    May 3 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    Bug I presume?

  12. Markus W

    May 4 Pre-Release Testers, Xojo Pro Answer #JeSuisHuman Germany, Heidelb...

    Feedback Case #55604

  13. Greg O

    May 4 Xojo Inc

    @Markus W Feedback Case #55604

    Thanks Markus. Its amazing my to me that no one has run into this before now.

  14. Markus W

    May 4 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...
    Edited 3 weeks ago

    @Greg OLone Thanks Markus. Its amazing my to me that no one has run into this before now.

    Dito. I thought it must be something I’m doing wrong because surely that would have been reported before …

    And thanks for your help!

or Sign Up to reply!