[Ur] Access to event object on onclick/et al

Adam Chlipala adamc at impredicative.com
Sat Jun 23 10:17:39 EDT 2012


I'm coming back to thinking about this after a long delay (sorry!).  
Does anyone know if the event attributes shown below are sufficiently 
cross-browser to make sense to build into the Ur/Web basis?

Vladimir Shabanov wrote:
> 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.

Hmm.  Somehow this strikes me as a bit too overload-y for my tastes. :)



More information about the Ur mailing list