macOS: Keyboard events aren't forwarded to the WebView
On macOS, when loading a website, the input is not forwarded to the window but remains in the terminal. Code to reproduce:
const std = @import("std");
const webui = @import("webui");
pub fn main() !void {
// Create new windows
var nwin = webui.newWindow();
// Show a new WebView window
_ = nwin.showWv("https://www.google.com");
// Wait until all windows get closed
webui.wait();
// Free all memory resources (Optional)
webui.clean();
}
Moreover, the instance eventually quits by itself after some ~10 seconds
the instance eventually quits by itself after some ~10 seconds
Yes, it will auto close because https://www.google.com does not have webui.js. You need to add it to your HTML UI to create a connection between the window and your backend.
So can we close this issue?
I think it should be possible to open the webview and interact with the keyboard even without connection to the backend. I don't need it for what I'm trying to do so it shouldn't be a requirement in my opinion; I just need to open the webview and interact with it normally
In order for webui to correctly control the webview, it needs to inject webui.js, otherwise the webview will be out of control. This is why webui will forcefully kill the webview when it cannot connect to the webview.
But I don't need webui to control the webview, just spawn it and eventually kill it (if needed) which as far as I understand, it can already do even without injecting webui. If it's against your intended design, that's another story
This cannot be solved by the wrapper. Maybe you can make a request to the webui main repository.
Gotcha, thanks!
If it's against your intended design, that's another story
I guess yes, webui is designed to connect UI to backend using webui.js, but if you need to interact with window itself using webview APIs then you should either manually modify the webui.c, or use webview for that, then later add webui to connect to UI if needed.