ClearRect vs DrawPicture transparency 100%

I still try to optimise my Gamelan application and stumbled over this:
I’ve a canvas based custom control with a picture as backdrop. To highlight parts of the picture (played keys of the instrument) I draw semi-transparent rectangles over it. Now to un-highlight, running on mojave I can just do a ClearRect to remove the drawn rectangle, but on high sierra and before, this clears out the backdrop too.
Is this a known/documented behaviour, or a bug either in mojave or high sierra?
I can instead of ClearRect just draw another picture with 100% transparency, but ClearRect would be faster.

What about to draw the previous contents (and not clearing the “highlight part”) ?

And, if you have transparent parts in the previous contents, fill the rect with the dominent color, then place the previous contents there.

BTW: you mean .ClearRect 0,0,100,20 remove the whole backdrop ?
In that case, this probably is a bug.

I hope you had an happy Christmas.

Either do a backdrop and do nothing with it. Or do your complete drawing in the Paint event without backdrop.

@Beatrix Willius
Had just a look at my code again. I’m not using a backdrop, it’s a separate canvas lying behind the control.

From the documentation:
Graphics.ClearRect(X As Double, Y As Double, Width As Double, Height As Double)
Clears the rectangle described by the parameters passed by filling it with the background color of the parent window.

this would suggest, that the pre mojave behaviour would be the correct one, clearing everything down to the window background?

@Emile Schwarz the previous contents is nothing, that’s why I did the ClearRect. Workaround now is draw a transparent picture with nothing;-)
And yes, we had a nice big family gathering last night, hope you had a nice evening too!

@Otmar Kramis: oh, this is even worse. Please try with one canvas only.

@Beatrix Willius, can you explain further, the background canvas is not part of the control, just lying underneath and only has to be drawn when the window size changes.

then why are you messing with it (clearrect etc)…a canvas is altered by its PAINT event (remember its not persistant), and if you set a backdrop, then it won’t change until you specifically change it
anything you do in other controls will have NO effect on the canvas itself.

Can I re-suggest that you set the image as the .backdrop property of the canvas (usually needs doing once only when the window is displayed),
and then draw (or not) transparent rectangles in the paint event.
I gave you sample code in the other post using RectShapes (you don’t need to create transparent pictures)

You had something like 6 rects that you might draw on the image.?
All you need do is decide which to draw, and .invalidate the canvas.
This takes virtually no time at all.

@Dave S, @Jeff Tullin, thanks for insisting. I really do not need to clear anything, just not drawing is enough, so my question is irrelevant. And drawing RectShapes is indeed much faster, so the slowness of my MBP2018 2d drawing becomes irrelevant too;-)