From 3d0d5d88458112e5cc276f650e02609dc85c5b87 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 8 Oct 2026 19:26:47 +0200 Subject: juicy event handler --- src/app/components/hello/root.zig | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/app/components') 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), + }); } -- cgit v1.2.3-70-g09d2