╭ changed ────────╮ │src/main_wasm.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │66 try root_ptr.input(key, root_ptr.getFocus()); │ │67 } │ │68 │ │69 +fn onMouseClick(x: usize, y: usize) !void { │ │70 + const root_ptr = if (root) |*root_value| root_value else return error.NotStarted; │ │71 + const root_focus = root_ptr.getFocus(); │ │72 + var iter = root_focus.children.iterator(); │ │73 + while (iter.next()) |entry| { │ │74 + const child = entry.value_ptr.*; │ │75 + if (!child.focus.focusable) continue; │ │76 + const r = child.rect; │ │77 + if (x >= r.x and y >= r.y and x < r.x + r.size.width and y < r.y + r.size.height) {│ │78 + try root_focus.setFocus(entry.key_ptr.*); │ │79 + break; │ │80 + } │ │81 + } │ │82 +} │ │83 + │ │84 fn consoleLog(arg: []const u8) void { │ │85 _consoleLog(arg.ptr, @intCast(arg.len)); │ │86 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │126 }; │ │127 } │ │128 │ │129 +export fn _onMouseClick(x: u32, y: u32) void { │ │130 + onMouseClick(x, y) catch |err| { │ │131 + var buf: [256]u8 = undefined; │ │132 + const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable;│ │133 + consoleLog(str); │ │134 + }; │ │135 +} │ │136 + │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯