ClickEvent won't be called if VisaulElement gets disabled during same ClickEvent

Basically I have buttons that change screens (my class inherited VisualElement) and call “SetEnabled” on it, to free resources of event system.
But it appears, that all buttons that do that, will be with only one callback.
Basically I click button, it gets ClickEvent: screen changes and calls SetEnabled on parent VisualElement of that button, all other callbacks registered under ClickEvent are discarded. And thus I can’t register any more callbacks to that button.

Is that supposely a bug or there supposed to be some workaround for that?

SetEnabled(false) makes the element looks disabled and will prevent pointer and keyboard interaction with it. You might want to use UnregisterCallback instead to remove your callbacks

I see, but ngl making it the way, so at least all current ClickEvent callback queue is finished would be great.
Way less code to manage yourself.

1 Like