Component preview on/off change event

Does turning a component’s preview on or off raise an event? If so I can’t seem to find it.

Context: I’m sending custom geometry to the render pipeline (not the display pipeline), and I need to keep my MeshProvider informed of its visibility. I suspect the fact that the CustomPreview component hasn’t solved this problem means there isn’t an easy solution. :grimacing:

I guess one obvious workaround would be overriding the component menu items entirely. This would allow slipping in a replacement “Preview” item whose click events could be handled. I’ll go that route unless someone has a better idea…

Better idea: The component re-renders on the canvas whenever the preview is turned on/off. One can track this from the attributes render override, and raise an event when the Hidden state changes. This also works for hiding/showing multiple components at once, which the previous suggestion does not. Tagging this as solved (for my purposes, at least).

1 Like

You subscribe ObjectChanged and check if it is Preview type:

  this.ObjectChanged += (s, e) =>
            {
                if (e.Type == GH_ObjectEventType.Preview)
                {
                    //do something
                }

            };