diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-08 19:26:47 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-08 19:26:47 +0200 |
| commit | 3d0d5d88458112e5cc276f650e02609dc85c5b87 (patch) | |
| tree | 7b0a48f7f7ef0af82360aa356b88a83b7dcfd699 /src/app/components/hello | |
| parent | 0260f392c19db7911496172c7d43d1178c6215cb (diff) | |
juicy event handler
Diffstat (limited to 'src/app/components/hello')
| -rw-r--r-- | src/app/components/hello/root.zig | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/app/components/hello/root.zig b/src/app/components/hello/root.zig index 761f46b..6dafd98 100644 --- a/src/app/components/hello/root.zig +++ b/src/app/components/hello/root.zig @@ -18,7 +18,18 @@ pub fn init(self: *Self, element: *z.Object) void { self.counter = 0; } -pub fn clicked(self: *Self) void { +pub fn clicked(self: *Self, event: *z.Object) !void { + var env: z.Env = .init(std.heap.wasm_allocator); + defer env.deinit(); + self.counter += 1; - std.log.info("clicked {} times", .{self.counter}); + + const x = event.get(&env, "x"); + const y = event.get(&env, "y"); + + std.log.info("clicked {} times at ({}, {})", .{ + self.counter, + try x.await(&env, .uint), + try y.await(&env, .uint), + }); } |