diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-04 16:55:56 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-04 16:58:19 +0200 |
commit | 01027f1749c80ce6def8546cb4ee43a5db064c1e (patch) | |
tree | a02d516b4361a4238a9f54cf02258ea658e15a29 /src/html | |
parent | c355c176863a930d2107254198749f420f272c06 (diff) | |
download | chawan-01027f1749c80ce6def8546cb4ee43a5db064c1e.tar.gz |
Event: add some properties, js: add defineConsts
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/event.nim | 19 |
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) |