Mercurial > urweb
comparison lib/ur/basis.urs @ 1783:5bc4fbf9c0fe
New event records for key and mouse handlers
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 21 Jul 2012 10:02:53 -0400 |
parents | 818d4097e2ed |
children | ffd7ed3bc0b7 |
comparison
equal
deleted
inserted
replaced
1782:61c7eb1d3867 | 1783:5bc4fbf9c0fe |
---|---|
782 unit -> tag attrs ([Body] ++ ctx) [] [] [] | 782 unit -> tag attrs ([Body] ++ ctx) [] [] [] |
783 | 783 |
784 val br : bodyTagStandalone [Id = id] | 784 val br : bodyTagStandalone [Id = id] |
785 | 785 |
786 con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit] | 786 con focusEvents = [Onblur = transaction unit, Onfocus = transaction unit] |
787 con mouseEvents = [Onclick = transaction unit, Ondblclick = transaction unit, | 787 |
788 Onmousedown = transaction unit, Onmousemove = transaction unit, | 788 datatype mouseButton = Left | Right | Middle |
789 Onmouseout = transaction unit, Onmouseover = transaction unit, | 789 |
790 Onmouseup = transaction unit] | 790 type mouseEvent = { ScreenX : int, ScreenY : int, ClientX : int, ClientY : int, |
791 con keyEvents = [Onkeydown = int -> transaction unit, Onkeypress = int -> transaction unit, | 791 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool, |
792 Onkeyup = int -> transaction unit] | 792 Button : mouseButton } |
793 | |
794 con mouseEvents = map (fn _ :: Unit => mouseEvent -> transaction unit) | |
795 [Onclick, Ondblclick, Onmousedown, Onmousemove, Onmouseout, Onmouseover, Onmouseup] | |
796 | |
797 type keyEvent = { KeyCode : int, | |
798 CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool } | |
799 | |
800 con keyEvents = map (fn _ :: Unit => keyEvent -> transaction unit) | |
801 [Onkeydown, Onkeypress, Onkeyup] | |
802 | |
793 (* Key arguments are character codes. *) | 803 (* Key arguments are character codes. *) |
794 con resizeEvents = [Onresize = transaction unit] | 804 con resizeEvents = [Onresize = transaction unit] |
795 con scrollEvents = [Onscroll = transaction unit] | 805 con scrollEvents = [Onscroll = transaction unit] |
796 | 806 |
797 con boxEvents = focusEvents ++ mouseEvents ++ keyEvents ++ resizeEvents ++ scrollEvents | 807 con boxEvents = focusEvents ++ mouseEvents ++ keyEvents ++ resizeEvents ++ scrollEvents |
953 val onConnectFail : transaction unit -> transaction unit | 963 val onConnectFail : transaction unit -> transaction unit |
954 val onDisconnect : transaction unit -> transaction unit | 964 val onDisconnect : transaction unit -> transaction unit |
955 val onServerError : (string -> transaction unit) -> transaction unit | 965 val onServerError : (string -> transaction unit) -> transaction unit |
956 | 966 |
957 (* More standard document-level JavaScript handlers *) | 967 (* More standard document-level JavaScript handlers *) |
958 val onClick : transaction unit -> transaction unit | 968 val onClick : (mouseEvent -> transaction unit) -> transaction unit |
959 val onDblclick : transaction unit -> transaction unit | 969 val onDblclick : (mouseEvent -> transaction unit) -> transaction unit |
960 val onKeydown : (int -> transaction unit) -> transaction unit | 970 val onKeydown : (keyEvent -> transaction unit) -> transaction unit |
961 val onKeypress : (int -> transaction unit) -> transaction unit | 971 val onKeypress : (keyEvent -> transaction unit) -> transaction unit |
962 val onKeyup : (int -> transaction unit) -> transaction unit | 972 val onKeyup : (keyEvent -> transaction unit) -> transaction unit |
963 val onMousedown : transaction unit -> transaction unit | 973 val onMousedown : (mouseEvent -> transaction unit) -> transaction unit |
964 val onMouseup : transaction unit -> transaction unit | 974 val onMouseup : (mouseEvent -> transaction unit) -> transaction unit |
965 | 975 |
966 (* Prevents default handling of current event *) | 976 (* Prevents default handling of current event *) |
967 val preventDefault : transaction unit | 977 val preventDefault : transaction unit |
968 (* Stops propagation of current event *) | 978 (* Stops propagation of current event *) |
969 val stopPropagation : transaction unit | 979 val stopPropagation : transaction unit |