[Lazarus] RegisterWSComponent documentation?

Zoë Peterson zoe at scootersoftware.com
Tue Nov 10 22:27:57 CET 2020

Is there any documentation on how RegisterWSComponent works with 
creating classes at runtime?

I'm specifically looking at TTreeView and TCustomControl, which both 
have WS classes, TWSTreeView and TWSCustomControl, and widgetset 
specific subclasses, TCocoaWSTreeView and TCocoaWSCustomControl.  It 
looks like it's creating new classes at runtime that somehow combine 
TCocoaWSTreeView and TCocoaWSCustomControl together, but it's not clear.

If I have my own class (TUiTreeView) and I want to register a subclass 
of my own to customize some behavior, should TUiCocoaWSTreeView descend 
from TCocoaWSTreeView or TCocoaWSCustomControl?  Does it matter?  If I 
have a TUiCocoaWSCustomControl too, which has a bunch of behavior I want 
to share, can I have TUiCocoaWSTreeView descend from that?  Does the 
answer change if I add a new virtual method in TUiCocoaWSCustomControl?

This is an issue for me because on macOS 10.14 and later, treeviews 
should use an NSVisualEffectView for their background rather than using 
a plain fillRect(clWindow).  I have that working in our own wrapper 
classes, but I'm not sure if I'm doing something dangerous.  I would 
love to submit the above back to the LCL for inclusion in stock Lazarus, 
but to allow descendants to hook it properly, I'd want a virtual method 
in TCocoaWSCustomControl that TCocoaWSTreeView could override, and I 
assume that isn't supported.

Zoë Peterson
Scooter Software

More information about the lazarus mailing list