comparison lib/ur/basis.urs @ 2156:d857da05f042

Allow mouse and key events for <body>
author Adam Chlipala <adam@chlipala.net>
date Thu, 02 Jul 2015 12:42:49 -0400
parents 3ca67d73fa5d
children 9c8016d99969
comparison
equal deleted inserted replaced
2155:7ce804ecd56b 2156:d857da05f042
809 809
810 val head : unit -> tag [Data = data_attr] html head [] [] 810 val head : unit -> tag [Data = data_attr] html head [] []
811 val title : unit -> tag [Data = data_attr] head [] [] [] 811 val title : unit -> tag [Data = data_attr] head [] [] []
812 val link : unit -> tag [Data = data_attr, Id = id, Rel = string, Typ = string, Href = url, Media = string] head [] [] [] 812 val link : unit -> tag [Data = data_attr, Id = id, Rel = string, Typ = string, Href = url, Media = string] head [] [] []
813 813
814 val body : unit -> tag [Data = data_attr, Onload = transaction unit, Onresize = transaction unit, Onunload = transaction unit, Onhashchange = transaction unit] 814 datatype mouseButton = Left | Right | Middle
815
816 type mouseEvent = { ScreenX : int, ScreenY : int, ClientX : int, ClientY : int,
817 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool,
818 Button : mouseButton }
819
820 con mouseEvents = map (fn _ :: Unit => mouseEvent -> transaction unit)
821 [Onclick, Oncontextmenu, Ondblclick, Onmousedown, Onmouseenter, Onmouseleave, Onmousemove, Onmouseout, Onmouseover, Onmouseup]
822
823 type keyEvent = { KeyCode : int,
824 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool }
825
826 con keyEvents = map (fn _ :: Unit => keyEvent -> transaction unit)
827 [Onkeydown, Onkeypress, Onkeyup]
828
829 val body : unit -> tag ([Data = data_attr, Onload = transaction unit, Onresize = transaction unit, Onunload = transaction unit, Onhashchange = transaction unit]
830 ++ mouseEvents ++ keyEvents)
815 html body [] [] 831 html body [] []
832
816 con bodyTag = fn (attrs :: {Type}) => 833 con bodyTag = fn (attrs :: {Type}) =>
817 ctx ::: {Unit} -> 834 ctx ::: {Unit} ->
818 [[Body] ~ ctx] => 835 [[Body] ~ ctx] =>
819 unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] [] 836 unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
820 con bodyTagStandalone = fn (attrs :: {Type}) => 837 con bodyTagStandalone = fn (attrs :: {Type}) =>
824 841
825 val br : bodyTagStandalone [Data = data_attr, Id = id] 842 val br : bodyTagStandalone [Data = data_attr, Id = id]
826 843
827 con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit] 844 con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit]
828 845
829 datatype mouseButton = Left | Right | Middle
830
831 type mouseEvent = { ScreenX : int, ScreenY : int, ClientX : int, ClientY : int,
832 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool,
833 Button : mouseButton }
834
835 con mouseEvents = map (fn _ :: Unit => mouseEvent -> transaction unit)
836 [Onclick, Oncontextmenu, Ondblclick, Onmousedown, Onmouseenter, Onmouseleave, Onmousemove, Onmouseout, Onmouseover, Onmouseup]
837
838 type keyEvent = { KeyCode : int,
839 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool }
840
841 con keyEvents = map (fn _ :: Unit => keyEvent -> transaction unit)
842 [Onkeydown, Onkeypress, Onkeyup]
843 846
844 (* Key arguments are character codes. *) 847 (* Key arguments are character codes. *)
845 con resizeEvents = [Onresize = transaction unit] 848 con resizeEvents = [Onresize = transaction unit]
846 con scrollEvents = [Onscroll = transaction unit] 849 con scrollEvents = [Onscroll = transaction unit]
847 850