simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
718 stars 50 forks source link

Add ability to close window with `Ctrl+Q` #25

Closed narimiran closed 6 years ago

narimiran commented 6 years ago

Currently window can be closed with Alt+F4. Can Ctrl+Q be added, as it is quite common shortcut for that?

data-man commented 6 years ago

Not for Windows. https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts

simonkrauter commented 6 years ago

@narimiran I think the shortcut should NOT be added in general to NiGui. But you can do this in your application. I have just implemented it.

Example code:

window.onKeyDown = proc(event: KeyboardEvent) =
  # Ctrl + Q -> Quit application
  if Key_Q.isDown() and (Key_ControlL.isDown() or Key_ControlR.isDown()):
    app.quit()
narimiran commented 6 years ago

Thanks for adding it to the examples. I'll close this.