Get custom canvas control to follow enabled state of GroupBox

Hi, I have a custom control based on a canvas. When I place this control in a GroupBox, is there a way I can get it to automatically follow the enabled state of the GroupBox like say a CheckBox does?

Thanks in advance,


Inside your Canvas.Paint put

[code]If Me.Parent <> Nil And Me.Parent.Enabled = False Then
system.DebugLog(“disabled paint”)

g.ForeColor = Color.DarkGray
g.FillRect(0, 0, g.Width, g.Height)
system.DebugLog(“enabled paint”)

g.ForeColor = Color.Black
g.FillRect(0, 0, g.Width, g.Height)
End If

I hope that paint gets called on macos/linux as it does on windows when the parent is enabled/disabled, aka. tested working in windows :wink:

Edit: Altered things so it works inside/outside of a container and defaults to enabled if not in one.

Thanks Julian. Works on macOS and Win10.