summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2015-07-02 12:42:49 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2015-07-02 12:42:49 -0400
commit030173645dbd08281dc59e3673f7f379619d523f (patch)
tree84c32b122c45030cf86bff3b738bc742870b36eb
parent9e06bc7fb086af288c0c6646d411dbc20bb5b628 (diff)
Allow mouse and key events for <body>
-rw-r--r--lib/ur/basis.urs33
-rw-r--r--tests/bodyClick.ur6
2 files changed, 24 insertions, 15 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 56c8d767..2defec9e 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -811,21 +811,6 @@ val head : unit -> tag [Data = data_attr] html head [] []
val title : unit -> tag [Data = data_attr] head [] [] []
val link : unit -> tag [Data = data_attr, Id = id, Rel = string, Typ = string, Href = url, Media = string] head [] [] []
-val body : unit -> tag [Data = data_attr, Onload = transaction unit, Onresize = transaction unit, Onunload = transaction unit, Onhashchange = transaction unit]
- html body [] []
-con bodyTag = fn (attrs :: {Type}) =>
- ctx ::: {Unit} ->
- [[Body] ~ ctx] =>
- unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
-con bodyTagStandalone = fn (attrs :: {Type}) =>
- ctx ::: {Unit}
- -> [[Body] ~ ctx] =>
- unit -> tag attrs ([Body] ++ ctx) [] [] []
-
-val br : bodyTagStandalone [Data = data_attr, Id = id]
-
-con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit]
-
datatype mouseButton = Left | Right | Middle
type mouseEvent = { ScreenX : int, ScreenY : int, ClientX : int, ClientY : int,
@@ -841,6 +826,24 @@ type keyEvent = { KeyCode : int,
con keyEvents = map (fn _ :: Unit => keyEvent -> transaction unit)
[Onkeydown, Onkeypress, Onkeyup]
+val body : unit -> tag ([Data = data_attr, Onload = transaction unit, Onresize = transaction unit, Onunload = transaction unit, Onhashchange = transaction unit]
+ ++ mouseEvents ++ keyEvents)
+ html body [] []
+
+con bodyTag = fn (attrs :: {Type}) =>
+ ctx ::: {Unit} ->
+ [[Body] ~ ctx] =>
+ unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
+con bodyTagStandalone = fn (attrs :: {Type}) =>
+ ctx ::: {Unit}
+ -> [[Body] ~ ctx] =>
+ unit -> tag attrs ([Body] ++ ctx) [] [] []
+
+val br : bodyTagStandalone [Data = data_attr, Id = id]
+
+con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit]
+
+
(* Key arguments are character codes. *)
con resizeEvents = [Onresize = transaction unit]
con scrollEvents = [Onscroll = transaction unit]
diff --git a/tests/bodyClick.ur b/tests/bodyClick.ur
new file mode 100644
index 00000000..9dcc64cf
--- /dev/null
+++ b/tests/bodyClick.ur
@@ -0,0 +1,6 @@
+fun main () : transaction page = return <xml>
+ <body onclick={fn _ => alert "You clicked the body."}
+ onkeyup={fn _ => alert "Key"}>
+ <p>Text</p>
+ </body>
+</xml>