Mercurial > urweb
changeset 1789:2e01a36701eb
Fix bug in handling of event attributes within client-side widgets
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 21 Jul 2012 21:07:15 -0400 |
parents | f57983ba2a36 |
children | 56b8efff64e7 |
files | src/monoize.sml tests/ctextboxAttrs.ur |
diffstat | 2 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/monoize.sml Sat Jul 21 15:34:07 2012 -0400 +++ b/src/monoize.sml Sat Jul 21 21:07:15 2012 -0400 @@ -3441,10 +3441,21 @@ | (x, e, _) => if String.isPrefix "On" x then let + val arg = if String.isPrefix "Onkey" x then + SOME (L'.EFfiApp ("Basis", "keyEvent", []), loc) + else if String.isSuffix "click" x orelse String.isPrefix "Onmouse" x then + SOME (L'.EFfiApp ("Basis", "mouseEvent", []), loc) + else + NONE + + val e = liftExpInExp 0 e + + val e = case arg of + NONE => e + | SOME arg => (L'.EApp (e, arg), loc) + val e = (L'.EAbs ("_", (L'.TRecord [], loc), (L'.TRecord [], loc), - (L'.EApp ((L'.EApp (liftExpInExp 0 e, - (L'.EFfiApp ("Basis", "kc", []), loc)), - loc), (L'.ERecord [], loc)), loc)), loc) + (L'.EApp (e, (L'.ERecord [], loc)), loc)), loc) in case x of "Onkeyup" =>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ctextboxAttrs.ur Sat Jul 21 21:07:15 2012 -0400 @@ -0,0 +1,6 @@ +fun main () : transaction page = + s <- source "Initial"; + return <xml><body> + <ctextbox source={s} onclick={fn ev => alert ("Clicky " ^ show ev.ScreenX)} + onkeypress={fn ev => alert ("Code " ^ show ev.KeyCode)}/> + </body></xml>