Printf erases the screen (using the MoSync library)

111 Views Asked by At

I have some simple code that looks like this:

printf("Press zero or back to exit\n");
maSetColor(0x0055ff);
maFillRect(10,10,100,100);
maUpdateScreen();

This runs, but when it's like this:

maSetColor(0x0055ff);
maFillRect(10,10,100,100);
maUpdateScreen();
printf("Press zero or back to exit\n");

printf erases the screen.

Why is this? Is this a normal property of printf()? Is there a different print function I should use to print on top of everything, instead of erasing everything? I know I can use MoSync's MaDrawText() instead, but I was wondering if there was a print function that would also work.

1

There are 1 best solutions below

0
On

This is expected behavior, printf() will display text in a seperate screen. The alternative is maDrawText(int left, int top, const char* str); which will allow you to draw the text in the paint area.

Your code could look like:

//Draw the Rectangle
maSetColor(0x0055ff);
maFillRect(10,10,100,100);

//Draw the text
maSetColor(0xffffff);
maDrawText(10,10,"Press zero or back to exit");

//Update the screen to reflect changes
maUpdateScreen(); 

Your first example works because you are calling the function before you update the screen and hence printf() will not draw on top of your current drawing.