Skip to content

[Nim] How can I listen for click on window's close button ? #302

Closed Answered by hassandraga
loloof64 asked this question in Q&A
Discussion options

You must be logged in to vote

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
For more questions please o…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by loloof64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants