Grasshopper Text Dot visibility/overlap

Hello, I could make drawing the dots kind of work, but I still can’t make sure that the dots are removed properly once the component is deactivated or the C# script component gets deleted.

Where to remove the event handler for Rhino.Display.DisplayPipeline.DrawForeground?

The script is an edit of Draw To Screen Space Foreground From DrawViewportWires - #13 by mrhe

drawForegroundv2.gh (10.0 KB)

The post mentions my current problem:

This gets you 80% there. You will notice, however, that the dashboard is now persistent even if you remove the script from your document or switch to a different one. Ideally, you would unregister from the DrawForeground event handler in the following two cases but I only know how to do it from a compiled component. Maybe someone else can help you with the script component counterparts:

public override void DocumentContextChanged(GH_Document document, GH_DocumentContext context) {}

public override void RemovedFromDocument(GH_Document document) {}