mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
handle input selection when keydown
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user