aboutsummaryrefslogtreecommitdiff
path: root/src/app/components
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 19:26:47 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 19:26:47 +0200
commit3d0d5d88458112e5cc276f650e02609dc85c5b87 (patch)
tree7b0a48f7f7ef0af82360aa356b88a83b7dcfd699 /src/app/components
parent0260f392c19db7911496172c7d43d1178c6215cb (diff)
juicy event handler
Diffstat (limited to 'src/app/components')
-rw-r--r--src/app/components/hello/root.zig15
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),
+ });
}