Why does clearing a canvas clear the parent canvas in Firemonkey?

  

If I do the following for a TPaintBox, I clear the parent control as well as the paint control:

canvas.BeginScene;
canvas.Clear(TAlphaColors.Gray);
canvas.EndScene;

If I switch to ClearRect, it then works correctly:

canvas.BeginScene;
canvas.ClearRect(TRectF.Create(0, 0, width, height), TAlphaColors.Gray);
canvas.EndScene;

I’m guessing it’s because the paint box is sharing the parents canvas and clear works on that, but clear rect does the right thing. Can anyone confirm this?

Comments are closed.