Window Keyboard Event Binding #2359
-
|
Hello, One thing that I'm wanting to do is bind some keyboard events to my game in the same way the mouse bindiings are done. Essentially, I've got keys like A S D F J K that I'd like to be able to write a callback on key press. Binding mouse event in a window is as easy was writing a function that accepts a window and does whatever (firing twice - once on mouse down and again mouse release). Bonus question: Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Beta Was this translation helpful? Give feedback.
-
|
I think there are a couple of ways to deal with the button callback - you could run a loop (including a call to (BLOCK), so things don't lock up) that tests for when (KEYDOWNP 'keyname) happens, whenever the mouse/cursor is in the game window. Alternatively, I think you could make the keys interrupt characters using (INTERRUPTCHAR ...) [see the IRM for the documentation], and arm/disarm those when the mouse/cursor is in the game window.
…-- Nick
On Nov 7, 2025, at 18:49, Ryan Burnside ***@***.***> wrote:
I suppose the "Bonus" question has been answered by Medley itself.
Screenshot_20251107_194637.png (view on web) <https://github.com/user-attachments/assets/6206b076-f882-4f0e-8a0b-cccc53ac04ef>
I made a counting closure using FUNCTION/LAMNDA and was advised to use Common Lisp closures instead.
Fair enough. I guess my main question now is that button callback on a window'd project.
—
Reply to this email directly, view it on GitHub <#2359 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6DAWJA4SLQQE76QC6ZCXD33VK4DAVCNFSM6AAAAACLPTA7PCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIOJQHAZTMNI>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
|
Interlisp EVAL and Interlisp compiled code don't create lexical contexts. So (LET ((FOO 42)) (....)) doesn't create a lexical scope so there is nothing to close over. If you wrap it in a CL:LAMBDA though you'll get lexical bindings will return a lexical closure with the value of FOO captured (I changed it to INCF just to illustrate) |
Beta Was this translation helpful? Give feedback.



Interlisp EVAL and Interlisp compiled code don't create lexical contexts.
So (LET ((FOO 42)) (....))
doesn't create a lexical scope so there is nothing to close over.
If you wrap it in a CL:LAMBDA though you'll get lexical bindings
(CL:FUNCALL #'(CL:LAMBDA (&AUX (FOO 42)) (CL:INCF FOO))))
will return a lexical closure with the value of FOO captured (I changed it to INCF just to illustrate)