I'm trying to send various user input events to a virtual machine. The app is built in SwiftUI, so the VZVirtualMachineView
is part of a view controller wrapped in NSViewControllerRepresentable
. Non-modified keystrokes and mouse clicks work fine, but I can't send modified keystrokes (e.g., ⌘F). These come through without the modifier (e.g., plain F). I also haven't been able to get mouse scroll wheel events to do anything in the VM.
I installed a local event monitor with addLocalMonitorForEvents(matching:handler:)
. Before the VM boots and the VM view exists, typing myself generates events that I see with the monitor. After the VM boots, though, the monitor does not see any of my keystrokes.
The monitor never sees any of my programmatically generated events. I am sending these all through NSWindow.sendEvent(_:)
.
Is there anything special about VZVirtualMachineView
that might affect how it handles injected events?
It's obvious possible (likely) that I'm doing something wrong with how I build and/or send these events into the application. Can anyone point me to documentation or examples that aren't easily found through search engines?