-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Apologies if there's better forum for questions, but I've been banging my head on this for a little while and haven't figured it out yet.
Basically I want any press of the 'q' key to close the window the key was pressed in. I've registered a key-typed handler as follows:
(defmethod c2d/key-typed [window-name \q]
[event state]
(comment "What goes here? 🤔"))
And verified that it's called correctly, but I'm at a loss as to how to close the window.
Both of the solutions I thought of (adding a quit-requested
flag to the window's state) or just calling c2d/close-window
directly require a handle to the window (returned by c2d/show-window
), which I don't have here, and I haven't yet figured out if/how to obtain a handle to the window from the event object (despite a bit of digging through the Java object model reachable from the event).
Is it possible to obtain the window object from the event object? Or am I going to have to store the window in a global somewhere (i.e. an atom) and hardcode the handler to refer to it (which I'd like to avoid, if at all possible)?