summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-07-21 21:07:15 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-07-21 21:07:15 -0400
commitedd64e5edc98649b741dad91ce8c6a902492a1c7 (patch)
tree7722ce2ecf232751b9c69503698efd6661b4d04e
parent0d70a2d0f26350db55d68836a04fbefaabbd6e8a (diff)
Fix bug in handling of event attributes within client-side widgets
-rw-r--r--src/monoize.sml17
-rw-r--r--tests/ctextboxAttrs.ur6
2 files changed, 20 insertions, 3 deletions
diff --git a/src/monoize.sml b/src/monoize.sml
index 403e0b84..7b1da97a 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -3441,10 +3441,21 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
| (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" =>
diff --git a/tests/ctextboxAttrs.ur b/tests/ctextboxAttrs.ur
new file mode 100644
index 00000000..84cd087a
--- /dev/null
+++ b/tests/ctextboxAttrs.ur
@@ -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>