Canvas.Graphics Removed

Can anyone explain why fGraphics property was removed from Canvas in 2018R3?

Is the g as Graphics variable in the Canvas.Paint event only valid during that function (or functions it calls)?

For example, can I create Canvas2 that inherits Canvas and save the g variable in property Canvas2.fGraphics?

yes… but it can be passed from the Paint event to external methods to centralize your drawing logic

Canvas doesn’t inherit Canvas… [Ape doesn’t kill Ape… sorry old movie reference]

“g” is internal to the canvas that created it

.Graphics on windows / controls etc… is no longer allowed (it was deprecated a long time ago). You must use the graphics parameter passed in the Paint event. This can be passed to another function as a parameter if required.

I imagine holding onto the graphics parameter in a property would not be a good idea.

Hanging on to the graphics property is bound to cause issues. I’d suggest not doing it.

Because the OS finally hardened the rules about accessing the graphics context, so Xojo followed suit. It used to cause subtle, hard to track down errors, anyway, so it’s a good move.


No, you can’t.