handle input selection when keydown

This commit is contained in:
Pierre Tachoire
2025-12-29 11:39:57 +01:00
parent 3e52abf471
commit 2d6c37fa6f

View File

@@ -2510,6 +2510,13 @@ pub fn handleKeydown(self: *Page, target: *Node, event: *Event) !void {
// Handle printable characters // Handle printable characters
if (key.isPrintable()) { if (key.isPrintable()) {
// if the input is selected, replace the content.
if (input._selected) {
const new_value = try self.arena.dupe(u8, key.asString());
try input.setValue(new_value, self);
input._selected = false;
return;
}
const current_value = input.getValue(); const current_value = input.getValue();
const new_value = try std.mem.concat(self.arena, u8, &.{ current_value, key.asString() }); const new_value = try std.mem.concat(self.arena, u8, &.{ current_value, key.asString() });
try input.setValue(new_value, self); try input.setValue(new_value, self);