-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after setpublic ,browser does not work the same as it's autorun‘s window #38
Comments
// main.go
package main
import (
"fmt"
ui "github.com/webui-dev/go-webui/v2"
)
func greet(e ui.Event) string {
name, _ := ui.GetArg[string](e)
fmt.Printf("%s has reached the backend!\n", name)
jsResp := fmt.Sprintf("Hello %s 🐇", name)
return jsResp
//return "Hello World111"
}
func main() {
// Create a window.
w := ui.NewWindow()
//webui_set_public(public_window, true)
w.SetPublic("public_window", true)
// Bind a Go function.
ui.Bind(w, "greet", greet)
// Show frontend.
w.Show("index.html")
// Wait until all windows get closed.
ui.Wait()
} |
Thank you @GodGavin for reporting this, we will check this issue as soon as mainstream (core) v2.5 gets released. |
Thanks for providing the repro. To narrow it down we should check if this issue is limited to the Go binding. I have check with C and can reproduce it. Mirroring the repro to C and trying to call the bound function from the public win in the browser it is a:
#include "webui.h"
void greet(webui_event_t* e) {
const char* str_arg = webui_get_string(e);
printf("%s has reached the backend\n", str_arg);
webui_return_string(e, "some str return");
}
int main() {
size_t w = webui_new_window();
webui_bind(w, "greet", greet);
webui_set_public(w, true);
webui_show(w, "index.html");
webui_wait();
webui_clean();
return 0;
} |
The Poll: webui-dev/webui#434
document.addEventListener('DOMContentLoaded', function() {
// DOM is loaded. Check if `webui` object is available
if (typeof webui !== 'undefined') {
// Set events callback
webui.setEventCallback((e) => {
if (e == webui.event.CONNECTED) {
// Connection to the backend is established
// Now it's safe to call a backend function
myBackendFunction();
}
});
}
}); |
Description
this is the picture
Expected Behavior
it should display the same
Reproduction Steps
No response
Error Logs
No response
Possible Solution
No response
Version
v2.4.3-0.20240615225151-fa682814ad2c
Environment Details (OS name, version, etc.)
The text was updated successfully, but these errors were encountered: