Distinguishable Control base events?
Hi, I'm working on an F# wrapper for this lib: https://github.com/czifro-tech/FSharpUI . I'm have made quite a bit of progress as can be seen in the readme. I'm trying to provide a simple API where multiple types can use a single function to be altered some way. For instance, using reflection and generics, I refactored all code related to adding an event handler to a single function call:
// create a button and add a click event
create<Button>("Say Hello")
|> addOnEvent<EventArgs>(fun (sender,e) -> printfn "Hello!")
// create app and add on exit event
create<Application>()
|> addOnEvent<CancelEventArgs>(fun (sender,e) -> printfn "Goodbye!")
I have been able to do this for pretty much every class that I have wrapped that has some sort of event handler. The only two event handlers I cannot support this way and instead have specific functions for is Control::Resize and Control::LocationChanged. It would be nice if one of these used a subtype to EventArgs, like perhaps the following changes could happen:
public event EventHandler Resize;
// changes to...
public event EventHandler<ResizeEventArgs> Resize;
And perhaps add class:
public class ResizeEventArgs : EventArgs { }
The class would not need to do anything, instead it would just be for using reflection. It would really help provide a clean F# API. I don't see this hurting/breaking anything given that typically lambdas are used to add event handlers. I would be willing to submit a PR with the changes if it is something you would be willing to allow.