You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You could have a look at @ocharles bindings to virtual-dom for some inspiration here. If a callback is JSRef Event -> IO () you can have a function like this one from virtual dom:
onInput::MonadStateHTMLElementm=>DOMEventString->m()
onInput chan = on "input" f
where
f evt =do
t <- fromJSRef evt
for_ t (\t' ->do
t'' <- eventGetTarget t'
for_ t''
(htmlInputElementGetValue .
castToHTMLInputElement >=> (channel chan)))
onKeyPress::MonadStateHTMLElementm=>DOMEventInt->m()
onKeyPress (DOMEvent chan) = on "keypress" f
where
f evt =do
t <- fromJSRef evt
for_ t
(uiEventGetKeyCode .-- A little messy, but we're working with a dom-delegator 'KeyEvent' here.
(unsafeCastGObject ::GObject->UIEvent) .
toGObject >=> chan)
I use DOMEvent as the entry point to stuff messages into a channel, with Contravariant instance use to convert the information coming out of the handler to an Event type.
What types of events are there? Currently mouse, keyboard, change, focus.
What properties do they all hold? How do properties map from js to haskell?
The text was updated successfully, but these errors were encountered: