0 | module Text.Html.Event
 1 |
 2 | import Data.Maybe
 3 |
 4 | %default total
 5 |
 6 | --------------------------------------------------------------------------------
 7 | --          Event Info Types
 8 | --------------------------------------------------------------------------------
 9 |
10 | public export
11 | record WheelInfo where
12 |   constructor MkWheelInfo
13 |   deltaMode : Bits32
14 |   deltaX    : Double
15 |   deltaY    : Double
16 |   deltaZ    : Double
17 |
18 | public export
19 | record MouseInfo where
20 |   constructor MkMouseInfo
21 |   -- buttons
22 |   button  : Int16
23 |   buttons : Bits16
24 |
25 |   -- coordinates
26 |   clientX : Double
27 |   clientY : Double
28 |   offsetX : Double
29 |   offsetY : Double
30 |   pageX   : Double
31 |   pageY   : Double
32 |   screenX : Double
33 |   screenY : Double
34 |
35 |   -- keys
36 |   alt     : Bool
37 |   ctrl    : Bool
38 |   meta    : Bool
39 |   shift   : Bool
40 |
41 | public export
42 | record InputInfo where
43 |   constructor MkInputInfo
44 |   value   : String
45 |   checked : Bool
46 |
47 | public export
48 | record KeyInfo where
49 |   constructor MkKeyInfo
50 |   key         : String
51 |   code        : String
52 |   location    : Bits32
53 |   isComposing : Bool
54 |
55 |   -- control keys
56 |   alt         : Bool
57 |   ctrl        : Bool
58 |   meta        : Bool
59 |   shift       : Bool
60 |
61 |
62 | --------------------------------------------------------------------------------
63 | --          Events
64 | --------------------------------------------------------------------------------
65 |
66 | public export
67 | data DOMEvent : Type -> Type where
68 |   -- Mouse clicks
69 |   Click      : (MouseInfo -> Maybe a) -> DOMEvent a
70 |   DblClick   : (MouseInfo -> Maybe a) -> DOMEvent a
71 |   MouseDown  : (MouseInfo -> Maybe a) -> DOMEvent a
72 |   MouseUp    : (MouseInfo -> Maybe a) -> DOMEvent a
73 |
74 |   -- Mouse movement
75 |   MouseEnter : (MouseInfo -> Maybe a) -> DOMEvent a
76 |   MouseLeave : (MouseInfo -> Maybe a) -> DOMEvent a
77 |   MouseOver  : (MouseInfo -> Maybe a) -> DOMEvent a
78 |   MouseOut   : (MouseInfo -> Maybe a) -> DOMEvent a
79 |   MouseMove  : (MouseInfo -> Maybe a) -> DOMEvent a
80 |
81 |   -- Focus
82 |   Blur       : a -> DOMEvent a
83 |   Focus      : a -> DOMEvent a
84 |
85 |   -- Keyboard
86 |   KeyDown    : (KeyInfo -> Maybe a) -> DOMEvent a
87 |   KeyUp      : (KeyInfo -> Maybe a) -> DOMEvent a
88 |
89 |   -- Input
90 |   Change     : (InputInfo -> Maybe a) -> DOMEvent a
91 |   Input      : (InputInfo -> Maybe a) -> DOMEvent a
92 |
93 |   -- Routing
94 |   HashChange : a -> DOMEvent a
95 |
96 |   -- Wheel
97 |   Wheel      : (WheelInfo -> Maybe a) -> DOMEvent a
98 |