╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
215 const str = std.fmt.bufPrint(&buf, "onKeyDown: {}", .{err}) catch unreachable; 216 consoleLog(str); 217 }; 218 } 219 220 export fn _onMouseClick(focus_id: u32) void { 221 onMouseClick(focus_id) catch |err| { 222 var buf: [256]u8 = undefined; 223 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 224 consoleLog(str); 225 }; 226 } 227 228 export fn _setFocus(focus_id: u32) void { 229 setFocus(focus_id) catch |err| { 230 var buf: [256]u8 = undefined; 231 const str = std.fmt.bufPrint(&buf, "setFocus: {}", .{err}) catch unreachable; 232 consoleLog(str); 233 }; 234 } 235 236 // js calls this when the value of a native <input> changes; we replace 237 // the matching TextInput's content with the supplied utf-8 bytes. 238 export fn _setTextInputValue(focus_id: u32, value_ptr: [*]const u8, value_len: u32) void { 239 setTextInputValue(focus_id, value_ptr[0..value_len]) catch |err| { 240 var buf: [256]u8 = undefined; 241 const str = std.fmt.bufPrint(&buf, "setTextInputValue: {}", .{err}) catch unreachable; 242 consoleLog(str); 243 }; 244 } 245 246 fn setTextInputValue(focus_id: u32, bytes: []const u8) !void { 247 const root_ptr = if (root) |*r| r else return error.NotStarted; 248 const root_focus = root_ptr.getFocus(); 249 const child = root_focus.children.get(focus_id) orelse return error.UnknownFocusId; 250 switch (child.focus.kind) { 251 .text_input, .text_input_password, .text_area => {}, 252 else => return error.NotATextInput, 253 } 254 const ti = session.text_inputs.get(focus_id) orelse return error.UnknownFocusId; 255 try ti.setContent(allocator, bytes); 256 } 257