I have a drag widget that is automatically destroyed when I stop dragging it, which makes sense. But I want to override the destruction to change when the widget actually gets destroyed. I thought that the NativeDestruct() super code is what actually destroyed the widget, but when I overrode NativeDestruct() without the super, the widget is still destroyed as usual. No matter which functions I try to override, the widget is always destroyed somehow.
I tried to follow the code to see where Unreal actually destroys widgets, but I got stuck. My guesses were that Unreal was either calling NativeDestruct() or RemoveFromParent(), but I can’t figure out how either are implemented.
NativeDestruct() calls Destruct(), which is a blueprint-implemented event. But I can’t find where it is actually implemented. Rider can’t find any default implementations either.
RemoveFromParent() is a lot more complicated. It goes to the widget’s actual slot, and then removes that slot by removing the widget from its parent’s array of children and then invalidating the slot. This doesn’t actually destroy the widget, but it gets rid of every reference to the widget. So when garbage collection comes around, it removes the widget by calling Destruct(), but I still don’t know how that works.
This is at least my understanding of Unreal’s widget destruction system, though I could totally be wrong. I’m just hoping someone else could shed some light on how this works, and/or how I can override the destruction of my widget without actually destroying it?
Thanks in advance!