nih-plug icon indicating copy to clipboard operation
nih-plug copied to clipboard

Keyboard input issues

Open peastman opened this issue 8 months ago • 3 comments

This is tangentially related to #191, but it's not the same problem, and the workaround for that issue doesn't fix it.

I have a plugin (Chorus Ex Machina) whose UI includes text fields to type into. It's a singing synthesizer, and the text fields are to enter the text for it to sing, so they're essential for the plugin to be usable.

In some DAWs, you can't type anything into them. The host intercepts all keyboard input and processes it itself rather than forwarding it to the plugin. This happens in Ableton and Reaper, and possibly in others I haven't tried.

There are workarounds, but they aren't very satisfactory. Reaper has an option you can enable, "Send all keyboard input to plug-in". That works, but only if users know it exists and know to activate it. And then it goes too far in the other direction. It sends all keypresses to the plugin all the time, even when a text field isn't active. You can no longer use any keyboard shortcuts for anything when the plugin UI is active. Ableton has a similar option, but it's even less convenient because it requires editing a text file by hand. And then it has the same problem of blocking all shortcuts.

I contacted tech support for Reaper, and they told me it automatically detects when a text field has focus and directs keypresses appropriately. The problem is that egui, VIZIA, and Iced all draw their own widgets rather than using ones provided by the OS. The host doesn't know a text field has focus because as far as the OS is concerned, it isn't a real text field. It's just a decoration being drawn to the screen that mimics one.

Is there any way to solve this? The most obvious solution would be to support a UI framework that uses native widgets. Possibly Dioxus or Tauri would work? Or is there some other way to signal the host so it knows which keypresses to delegate and which to process itself?

peastman avatar Apr 26 '25 15:04 peastman

I've been trying to get Dioxus or Tauri working inside NIH-Plug, but without success. The barrier is that Wry, the webview library they're both based on, requires raw-window-handle version 0.6, but NIH-Plug requires version 0.5. This seems to make them fundamentally incompatible.

peastman avatar May 07 '25 03:05 peastman

@peastman Hey. Did you figure out how to handle keyboard input? Have the same problem. Reaper have an option, but other DAWs don't. In other plugins like Kontakt you are allowed to type text in search boxes without doing anything.

The question is where the problem lies?

  • vst3-sys
  • baseview
  • baseview vizia/iced implamentation
  • nig-plug itself
  • maybe editor window should be created in a different way to grab input?

Don't know where to start. Any clues?

fazibear avatar Sep 20 '25 11:09 fazibear

No, I never managed to fix it. The problem is described above: all the supported UI toolkits draw their own widgets instead of using standard OS ones. But the outdated dependencies make it impossible to use other toolkits.

peastman avatar Sep 20 '25 14:09 peastman