2024-11-27 08:09 AM
Hi,
Attached project starts with this screen:
When the white Box is moved to the left - with pressing 'a' key, it should completely go off the screen. However, one pixel thick line is always visible.
box1.setX ( box1.getX () - 1 );
box1.invalidate ();
Why ?
Thank you
Solved! Go to Solution.
2024-11-28 05:05 AM
Hello @ferro,
Try to put an invalidate before "box1.setX ( box1.getX () - 1 );".
With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that.
Best regards,
2024-11-28 05:05 AM
Hello @ferro,
Try to put an invalidate before "box1.setX ( box1.getX () - 1 );".
With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that.
Best regards,
2024-11-28 06:33 AM - edited 2024-11-28 06:35 AM
Thanks @LouisB
Interesting, in all Gfx examples - i've seen so far - invalidate is placed after all actions on widgets.
So this works as expected now, with a single 'invalidate ()' before:
box1.invalidate ();
box1.setX ( box1.getX () - 1 );
"With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that."
Thank you for this, will explore further.