egui-baseview icon indicating copy to clipboard operation
egui-baseview copied to clipboard

focusing issue in nih-plug / Windows 10

Open nat3Github opened this issue 1 year ago • 7 comments

In Windows 10, nih-plug standalone version egui does not get keyboard input, because the parented windows is never focused. always calling .focus() on the window fixes this but its not a nice solution.

nat3Github avatar Jun 19 '24 15:06 nat3Github

this was briefly talked about in the rust audio discord, basically keyboard focus with baseview is kind of a mess on windows, and ableton is partially to blame. i've tried fixing this but haven't had much luck

murl-digital avatar Jul 05 '24 23:07 murl-digital

@murl-digital your idea in past discord conversation + a post from an @Beepster fixed this for me. I have just maintained a fork of egui_baseview to keep this working in my plugins, but here is all I changed in egui_baseview to "make this work" although it doesn't feel like the right way :)

in src/window.rs at bottom of fn on_frame()

        if !full_output.platform_output.events.is_empty() || 
            full_output.platform_output.ime.is_some() {
            #[cfg(target_os = "windows")]
            window.focus();
        }

ardura avatar Aug 27 '24 14:08 ardura

That is kind of hacky, but if you think this is a good temporary fix I could merge it upstream.

BillyDM avatar Aug 27 '24 20:08 BillyDM

i recall someone somewhere saying there were problems or it didn't work exactly how it was expected to, but i reckon it's good enough

i think it may be smart to put it behind a feature gate in case it has unintended consequences

murl-digital avatar Aug 28 '24 06:08 murl-digital

Alright, I added a workaround in 6645c14

BillyDM avatar Aug 29 '24 20:08 BillyDM

This same issue also exists on macOS, and the same fix works for it. When writing a plugin with NIH-Plug and loading it in Reaper, the plugin doesn't get any keyboard input. If I modify the above workaround to also call window.focus() on macOS, it works correctly. Could the workaround be updated to apply on both platforms?

peastman avatar Mar 19 '25 23:03 peastman

I have decided to move my repositories to Codeberg. I have cloned the issues there.

BillyDM avatar Sep 22 '25 15:09 BillyDM