Problem with drawing on canvas

Hello everyone.
blocks

My app contains a canvas and a (return)button inside a full screen vertical arrangement.I also have a second full screen vertical arrangement with a textbox and a button - which is my "start screen".If I press the button on my "start screen" the contents of a text should be drawn on the canvas,which is currently hidden.By pressing the button the start screen will be hidden and the canvas made visible.Unfortunately the nothing is being drawn on the canvas the FIRST time the app is startet or initialized.But after using the return button beneath the canvas and pressing the start screen button again everything works perfectly.My uploaded app is just a demonstration.I would like to know the cause of the problem as my original (large)project has come to an end and I need to get this sorted out.
blocks

Canvas has to be visible to be drawn on?

Thanks for your quick reply - appreciated !
What bothers me is that it works after it fails the first time.One can change the text and it will be updated on the still hidden canvas.
I tried several constellations like unhide the canvas and then drawing values making sure that first the canvas appears and then writing values on to it.
It just doesn't work when I start the app.I am quite sure it's my fault I am currently just at my wits end.
It's my first posting here.Just started using App Inventor 4 weeks ago and I am still lacking some "in-depth" knowledge.I will give your answer some more consideration and might have some questions later on.

Could be a timing thing on app startup, you may need to give the canvas a little bit of time - 250msecs, to get its dimensions. Use a clock timer for this

This might be a possibility.I will give this a try.
As this is my first posting:
I can see my uploaded block picture but I can't find the aia-file which I also uploaded.
I'd like to know if both files are available for you and others in case I have other questions in future.
Thanks in advance

No AIA. Upload again.

Hmm this is weird - I'll try it again.
I am using the upload button of this text editor.
CanvasTest.aia (66.6 KB)

Try these blocks, which include a timer, works for me...

Yepp - your solution works !!!
I will implement your code tomorrow in my original project.Should work without any problems.
I just tried it with 1ms timer delay and it still did its job.But I think with 10ms i should be on the safe side
A big thank you from me - after days of coding I simply just didn't see the forest for the trees anymore and the idea with the timer didn't come to my mind.
I consider this problem as resolved.
greetings from Ireland - please excuse any grammar or spelling errors:english is not my native language....

The timer needs at least 20-25ms to work (or longer depending on the device). So it makes no sense (and it doesn't change anything) to set shorter times (1-10ms).

Thanks !
You might be right there.Delays up to 50ms should not cause any noticable delay.Releasing a button by me takes longer...:wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.