Quit Web View with cmd+q

Hi JUCE community,

we observed that when the focus is on the web page, keyshortcuts are not fired to the OS. So JUCE can not handle them. Any idea how to fix this? You can test this behavior with the WebBrowserDemo.

Thanks
David

Is one of your Components returning true from keyPressed()? That would “eat” the keystroke. By default, Components return false from that, and the WebBrowserComponent is a Component that does not override that function, so it shouldn’t have anything to do with causing that to happen, as far as I can see.

1 Like

I am 99% sure that the WebBrowserComponent hosts an OS component that is the web browser, and that it will process all keys, ie. they will not be processed through JUCE.

1 Like

Ah. Right you are. I wonder if you could override keyPressed() and have it return false for those kinds of key presses, or if the OS component is eating them before you’d even get a chance? If that’s the case, then there’s nothing you could do about it in JUCE, is there?

Maybe not a general key solution, but there is a callback WebBorwserComponent::windowCloseRequest(). I would expect this to be called when CMD+Q is pressed…

3 Likes

Thanks to all of you.

We found a solution. We catch the keyboard shortcuts and send a request to our juce backend to quit the application. This is only possible because we run a Webserver to communicate between our frontend which runs in a WebComponent and the juce backend.

No, we do not override these functions.