[Nim] How can I listen for click on window's close button ? #302
-
Hi ! First, I would like to say I'm so happy to start working on project with WebUi. I'm creating an application in Nim-WebUi. But I'm still struggling to find how to listen to a click on the window's exit button, so that I can call exit() in order to terminate the application ? This is my source file (light_them_all.nim) import std/os
import webui
proc main =
let window = newWindow()
window.bind("Close") do (_: Event):
exit()
window.rootFolder = currentSourcePath().parentDir() / "ui/dist"
window.show("index.html")
wait()
main() From what I've understood, Thank you in advance. 😃 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @loloof64, To listen to the close event of a window you can bind an empty "" to receive all events, including close event. import std/os
import webui
proc main =
let window = newWindow()
window.bind("") do (e: Event):
case e.eventType:
of EventsConnected:
# ...
of EventsDisconnected:
exit()
of EventsMouseClick:
# ...
of EventsNavigation:
# ...
else:
discard
window.rootFolder = currentSourcePath().parentDir() / "ui/dist"
window.show("index.html")
wait()
# If we reach here, then all windows are closed
# ...
main() Documentation: https://webui.me/docs/2.4/#/?id=events |
Beta Was this translation helpful? Give feedback.
Hey @loloof64, To listen to the close event of a window you can bind an empty "" to receive all events, including close event.
Documentation: https://webui.me/docs/2.4/#/?id=events
For more questions please o…