Devs: Suggestion for API Change to handle Events
One of the things I've run into a few times, especially when making sub classes, is overriding an event only to need that event externally as well.
I realize I can make a table of functions instead, but it seems like using a more traditional interface would be helpful.
AddEventHandler(EventId, caller, handlerFunction);
RemoveEventHandler(EventId, caller, handlerFunction);
Providing those at a base level along with a consistent set of events would be an outstanding addition to what is there and would avoid the issues surrounding a second override causing a logic error that is, at times, rather difficult to track down.
Extending this interface for your own custom events would involve something to the effect of:
CallHandlers(EventId, Sender, Args);
The only requirement is there needs to be a Turbine defined "User" id starting point. This is typically a number high enough that Turbine would never run out of reserved space, say 10000.
So maybe these are added to the Turbine.UI class:
Turbine.UI.EventId.MouseClicke d = 1;
Turbine.UI.EventId.MouseDown = 2;
Turbine.UI.EventId.MouseUp = 3;
Turbine.UI.EventId.KeyPressed = 4;
Turbine.UI.EventId.KeyDown = 5;
Turbine.UI.EventId.KeyUp = 6;
Turbine.UI.EventId.SelectionCh anged = 7;
Turbine.UI.EventId.User = 10000;
I leave the rest of the implementation up to you guys, but this would be a much cleaner interface than what is there now.