shallow icon indicating copy to clipboard operation
shallow copied to clipboard

UIKeyboard.Notifications members are unpleasant to use from F#

Open dvdsgl opened this issue 10 years ago • 0 comments

For example, to handle UIKeyboard.WillShowNotification, I have to call UIKeyboard.Notifications.ObserveWillShow, and manually wrap a function in an EventHandler:

UIKeyboard.Notifications.ObserveWillShow(EventHandler<_>(fun sender args -> 
    doSomething args))

When I would expect to be able to just do this:

UIKeyboard.WillShow.Add(doSomething)

To allow this, I added a static event to UIKeyboard:

module UIKeyboardNotifications =
    let WillShow = Event<_>()
    UIKeyboard.Notifications.ObserveWillShow(EventHandler<_>(fun sender args -> WillShow.Trigger(args)))

type UIKeyboard with
    static member WillShow = UIKeyboardNotifications.WillShow.Publish

But this should be part of MonoTouch.dll.

dvdsgl avatar Jun 19 '14 16:06 dvdsgl