Skip to content
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

bind "" event doesn't trigger when element has id #12

Open
hunar1997 opened this issue Nov 29, 2023 · 2 comments
Open

bind "" event doesn't trigger when element has id #12

hunar1997 opened this issue Nov 29, 2023 · 2 comments

Comments

@hunar1997
Copy link

Make this html file

<!DOCTYPE html>

<html>

<head>
  <script src="/webui.js"></script>
</head>

<body>
	<button id="test">click</button>
</body>

</html>

try with this C file

#include "webui.h"

void my_function(webui_event_t* e){
    printf("event\n");
}

int main() {
    size_t win = webui_new_window();
    webui_show(win, "index.html");
    webui_bind(win, "", my_function);
    webui_wait();

    return 0;
}

If you run this, clicking on the button or the surroundings will trigger an event
however trying the same with python

from webui import webui

MyWindow = webui.window()

def events(e : webui.event):
    print('event')
MyWindow.bind("", events)

MyWindow.show('index.html')

webui.wait()

Only triggers event when you click the surrounding, the button doesn't trigger it.

if I bind the id of that button it works, if the button didn't have id it works.. but if I catch all events then the ones with id don't trigger.

This happened in the python one, not the C one.. haven't tried other languages

One unrelated note: When I use linux, the C version launches firefox but the python version needs me to specify webui.browser.firefox otherwise the terminal closes immediately.

@hassandraga
Copy link
Member

Thank you for reporting this, I'm looking into it.

hassandraga added a commit to webui-dev/webui that referenced this issue Nov 29, 2023
@hassandraga
Copy link
Member

That was a bug in WebUI core. Fixed in the latest version.
Thank you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants