[Ur] Access to event object on onclick/et al
Vladimir Shabanov
vshabanoff at gmail.com
Sun May 20 15:46:12 EDT 2012
2012/5/20 Adam Chlipala <adamc at impredicative.com>:
> I do expect this will work, but it might be nicer to add a new argument(s)
> to appropriate event attribute types. Thoughts?
Looking at
https://developer.mozilla.org/en/DOM/DOM_event_reference
I think it worth to define mouseEvent and keyboardEvent types:
https://developer.mozilla.org/en/DOM/MouseEvent
con mouseEvent
= { ScreenX : int, ScreenY : int, ClientX : int, ClientY : int
, CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool
, Left : bool, Right : bool, Middle : bool }
https://developer.mozilla.org/en/DOM/KeyboardEvent
con keyboardEvent
= { KeyCode : int, Char : string
, CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool }
and change onclick/ondblclick/onmouse* to
mouseEvent -> transaction {}
and onkeydown/onkeypress/onkeyup to
keyboardEvent -> transaction {}
Interesting possibility is to allow both (transaction {}) and (event
-> transaction {}) as event handlers, so handlers that don't need
extra argument (like most of onclick handlers) could be written
without superfluous "fn _ => ". I think it's possible through type
class mechanism.
More information about the Ur
mailing list