I have no experience with subclassing stuff in Xojo or any other language so I am groping here.
I want to subclass the CheckBox control and add a TextColor property for the label but I can not figure out how to do this. I would be most grateful if you just point me at the proper documentation on how to do this.
BTW, don’t know if you are a Chiefs fan or not but Mahomes is a local boy from the next town over and was a local hero in high school and college. Congrats to the Chiefs.
If you are macOS only and have access to the MBS plugins here is a rough example i’ve just knocked up that shows how it could be done.
NOTE. The property TextColor below should be enabled in the control’s Inspector Behaviour.
[code]Class cCheckBox
Inherits Checkbox
Event Open()
Sub Open()
'update the initial appearance of the caption
Self.UpdateCaption
'raise the open event again so that it can be hooked into
RaiseEvent Open
End Sub
Private Sub UpdateCaption()
Dim attributedStringObj As NSAttributedStringMBS
Dim mutableAttributedStringObj As NSMutableAttributedStringMBS
If Self.NSButtonMBS <> Nil Then
attributedStringObj = NSAttributedStringMBS.attributedStringWithString(Self.Caption)
mutableAttributedStringObj = attributedStringObj.mutableCopy
mutableAttributedStringObj.addAttribute(NSAttributedStringMBS.NSForegroundColorAttributeName, New NSColorMBS(Self.mCaptionColour_), New NSRangeMBS(0, Len(Self.Caption)))
Pftt! Of course I’m a Chiefs fan. I watched every single one of the games when they were 2-14 (twice). I’ve been to training camp 8 years in a row. And stood out in sub-freezing temps to celebrate their Super Bowl victory.