# HG changeset patch # User Adam Chlipala # Date 1435855369 14400 # Node ID d857da05f042f1bd29b4ca4fe4f1fdef319cc3c8 # Parent 7ce804ecd56bdcffc841d9bfab8ecc57a809d2e6 Allow mouse and key events for diff -r 7ce804ecd56b -r d857da05f042 lib/ur/basis.urs --- a/lib/ur/basis.urs Thu Jun 11 19:38:03 2015 -0400 +++ b/lib/ur/basis.urs Thu Jul 02 12:42:49 2015 -0400 @@ -811,21 +811,6 @@ 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 @@ 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 -r 7ce804ecd56b -r d857da05f042 tests/bodyClick.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/bodyClick.ur Thu Jul 02 12:42:49 2015 -0400 @@ -0,0 +1,6 @@ +fun main () : transaction page = return + alert "You clicked the body."} + onkeyup={fn _ => alert "Key"}> +

Text

+ +