webui-dev / nim-webui

Use any web browser as GUI, with Nim in the backend and HTML5 in the frontend.
https://webui.me
MIT License
130 stars 9 forks source link

Error in the examples ? #32

Closed Sznymo closed 3 months ago

Sznymo commented 3 months ago

The "Call a Backend Function From JavaScript" example says to use "e.data". But Nim Lang displays an error: undeclared field: "data" for type webui.Event

AlbertShown commented 3 months ago

Seems the Nim docs are outdated! Thank you for reporting this, someone will update the docs soon.

For now, please refer to examples files instead.

Nim:

window.bind("Foo") do (e: Event):
    let str1 = e.getString(0) # First argument
    let number1 = e.getInt(1) # Second argument
    let status1 = e.getBool(2) # Third argument
...

JS:

Foo("Hello", 123, true);
Sznymo commented 3 months ago

That's how I already did it :) thanks

neroist commented 3 months ago

I'm so sorry! I'll make sure to update the docs soon :)