diff --git a/src/runtime/automation_widget_dispatch.zig b/src/runtime/automation_widget_dispatch.zig index 9209cdf0d..5aec44906 100644 --- a/src/runtime/automation_widget_dispatch.zig +++ b/src/runtime/automation_widget_dispatch.zig @@ -329,11 +329,12 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type { pub fn dispatchAutomationWidgetKeyInput(self: *Runtime, app: runtime_api.App(Runtime), key: AutomationWidgetKey) anyerror!void { const view_index = try automationGpuSurfaceViewIndexByLabel(self, key.view_label); try self.focusView(self.views[view_index].window_id, self.views[view_index].label); + const timestamp_ns = automationInputTimestampNs(); try self.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = self.views[view_index].window_id, .label = self.views[view_index].label, .kind = .key_down, - .timestamp_ns = automationInputTimestampNs(), + .timestamp_ns = timestamp_ns, .key = key.key, .text = key.text, .modifiers = .{ @@ -344,6 +345,20 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type { .primary = key.modifiers.primary, }, } }); + try self.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ + .window_id = self.views[view_index].window_id, + .label = self.views[view_index].label, + .kind = .key_up, + .timestamp_ns = timestamp_ns, + .key = key.key, + .modifiers = .{ + .shift = key.modifiers.shift, + .control = key.modifiers.control, + .option = key.modifiers.option, + .command = key.modifiers.command, + .primary = key.modifiers.primary, + }, + } }); } /// Drive a trackpad pinch through the real platform-event path: diff --git a/src/runtime/canvas_widget_event_tests.zig b/src/runtime/canvas_widget_event_tests.zig index 99123ead6..4b2803263 100644 --- a/src/runtime/canvas_widget_event_tests.zig +++ b/src/runtime/canvas_widget_event_tests.zig @@ -3297,6 +3297,61 @@ test "runtime resizes retained canvas resizable widgets from pointer drag" { } } +test "automation widget-key dispatches a complete key lifetime" { + const TestApp = struct { + key_down_count: u32 = 0, + key_up_count: u32 = 0, + last_key: []const u8 = "", + key_down_timestamp_ns: u64 = 0, + last_timestamp_ns: u64 = 0, + + fn app(self: *@This()) App { + return .{ .context = self, .name = "automation-widget-key", .source = platform.WebViewSource.html("