about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-04 16:55:56 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-04 16:58:19 +0200
commit01027f1749c80ce6def8546cb4ee43a5db064c1e (patch)
treea02d516b4361a4238a9f54cf02258ea658e15a29 /src/html
parentc355c176863a930d2107254198749f420f272c06 (diff)
downloadchawan-01027f1749c80ce6def8546cb4ee43a5db064c1e.tar.gz
Event: add some properties, js: add defineConsts
Diffstat (limited to 'src/html')
-rw-r--r--src/html/event.nim19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/html/event.nim b/src/html/event.nim
index 67e21b71..d862b40c 100644
--- a/src/html/event.nim
+++ b/src/html/event.nim
@@ -1,16 +1,31 @@
 import js/javascript
 
 type
+  EventPhase = enum
+    NONE = 0u16
+    CAPTURING_PHASE = 1u16
+    AT_TARGET = 2u16
+    BUBBLING_PHASE = 3u16
+
   Event* = ref object
+    ctype {.jsget: "type".}: string
+    target {.jsget.}: EventTarget
+    currentTarget {.jsget.}: EventTarget
+    eventPhase {.jsget.}: uint16
+    bubbles {.jsget.}: bool
+    cancelable {.jsget.}: bool
 
   EventTarget* = ref object of RootObj
 
-  #EventHandler* = proc(event: Event): JSValue #TODO ?
   EventHandler* = JSValue
 
 jsDestructor(Event)
 jsDestructor(EventTarget)
 
+func srcElement(this: Event): EventTarget {.jsfget.} =
+  return this.target
+
 proc addEventModule*(ctx: JSContext) =
-  ctx.registerType(Event)
+  let eventCID = ctx.registerType(Event)
+  ctx.defineConsts(eventCID, EventPhase, uint16)
   ctx.registerType(EventTarget)