The problem is I was planning to have separate script file the defined behavior of different elements. Which is something I always would have liked in html. Of course there would be a script in each xml ui document for the specific needs of that page like changing settings.
I am stuck on how I would implement scripts for each xml element. It seems like the game example is kind of what I want but I have no idea how I could pass callback functions out of a as script and into c++ to be called later by some c++. It would need to be specific to each object.
For example(not necessarily exactly like this)
class Dialog: IController
{
const ElementObj @self;
const ElementObj @button;
Dialog(ElementObj @obj)
{
// Keep the owner for later reference
@self = obj;
button = document.create("button");
self.append(button);
button.addEvent(@self.ClickCallback,"click");
}
void ClickCallback(ElementObj @element)
{
self.setProperty("backgroundColor","red");
}
}
Also any other ideas about this general problem and what is the best way to implement it would be much appreciated.