I found this older thread: Is there a way to register events for all elements of a class? which describes the call back itself.
But I have a couple of questions related to it:
What sort of object is “m_ButtonArrayContainer” in the example? It doesn’t appear to be a normal list or array as the method for call back appears specific to UI toolkit. For example I’m trying:
List<VisualElement> textureButtonList;
textureButtonList = ui.Query(className: "textureButton").ToList();
This creates the list and grabs the elements correctly, Just can’t seem to bind any callback off this list.
And looking a bit into the future here, I’d likely need to have some piece of data from each button that fires the event. In HTML you could just insert data attributes into the HTML tags like
"<div data-thing="42">
and just reference the data attribute for callbacks. Is there a similar function for UI toolkit?