diff options
Diffstat (limited to 'src/app/components/hello/root.zig')
| -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), + }); } |