Canvas text vanishes when Output window opens

What I’m trying to do:

Standard debugging of a form that includes Canvas objects. I created the objects programatically and set them to a color and text (via fill_text()).

Run program, text and background color look fine. Do some stuff, click on Output window, text vanishes but color is fine.

What I’ve tried and what’s not working:

Theoretically I can debug without viewing text, I just wonder why it’s happening so I don’t have to worry about the text vanishing at run time for my users.

Code Sample:

# code snippet

Clone link:
share a copy of your app
https://anvil.works/build#clone:FCK46AB5WAL7LE3E=7X4SZSJBI7C4BSBETN7DNA7B

To duplicate, Run, click Test Player. Click on a few squares. Click Output window.

Thanks,
Heidi

Hello there,

Have you tried searching the forum for "canvas/disappearing etc…? I have a vague memory of there being other posts on this but I’m not 100% sure.

I couldn’t find anything…

How about under “canvas resizing” or something like that. Pretty sure there is an old post that might be relevant if memory serves me correctly (which it often doesn’t!).

1 Like

Okay I found this: How Canvas.save() and Canvas.restore() actually work

Which shows how to save, then restore canvas if the form is resized. This is probably what happened - when the output window opened, the form resized.

But… can I capture a form.resize event? Don’t see on on the design page. So I won’t know when to trigger.

Ah okay I see it now! The canvas element has a resize event! Thanks for pointing me in the right direction.!

2 Likes