Fixing WebView Keyboard Focus Issue

Currently, when using juce::WebBrowserComponent on macOS, there is an issue in Ableton and Logic where computer keyboard input doesn’t go to the host. I have partially solved this problem by adding code directly to the .mm file as follows:

this->addMethod (@selector (keyDown:),
[](id self, SEL selector, NSEvent* event) 
{
    [[self nextResponder] keyDown:event];
});

this->addMethod (@selector (keyUp:),
[](id self, SEL selector, NSEvent* event) 
{
    [[self nextResponder] keyUp:event];
});

It’s not a complete solution, but it does solve the problem to some extent. The issue is that every time the JUCE repo is updated, I have to manually add this code to the .mm file, which is very tedious.

Is there a way to inject the Objective-C addMethod by subclassing juce::WebBrowserComponent?

Honestly, I wish the JUCE team would fix this so that I wouldn’t have to modify the .mm file myself.
I haven’t tested it on Windows, but I expect there might be a similar issue.

1 Like

Am I right that this approach forwards all keystrokes to the underlying application? Can you still interact with the web GUI using keystrokes?

This is something we are keeping an eye on, but a generic solution that ensures you can interact both with the system and your web GUI based on your preferences might require a more nuanced approach.

The above method is merely a stopgap measure. I handled it this way because keyboard input is not needed in the Web GUI, but as you mentioned, issues could arise. Is there any planned update regarding this part? My beta testers keep raising the issue that when the plugin is in focus, the computer keyboard does not trigger the DAW’s MIDI input. It seems that many producers are triggering MIDI notes with their computer keyboards rather than MIDI keyboards.

On a different note, the WebView Inspector is only active when built in Debug mode and becomes inactive in Release mode. Would it be possible to include this in the WebBrowserComponent Options so that right-clicking to open the inspector in Release mode is also enabled?

We do have plans to ease the usage of the WebView with keyboard shortcuts. We’ll keep your suggestion for the Release mode inspector as well, when we get around to this task.

Are there any solutions to this? We would really like to pass unused key strokes - mostly spacebar - to the host.

1 Like

Checking in here – any updates on this? Not being able to utilize the spacebar keypress in the daw certainly causes some issues for a plugin I’m working on…

Also checking in. That space bar key just gets swallowed up

1 Like

Same here - any updates?