onKeyPress but no onKeyDown or onKeyUp
3 posts
• Page 1 of 1
onKeyPress but no onKeyDown or onKeyUp
I'm using Dyalog APL/W-64 Version 18.2.48421. I have a need to know when a key is pressed (goes down) and is released (goes up). Unfortunately, Dyalog APL only seems to have onKeyPress, which activates on the key down. There is no built-in way to know when the key is released. I've resorted to writing a small ⎕NA routine calling the Windows GetKeyState function, which tells me whether the key is down, up, or toggled. This works, but it's inefficient. Windows has WM_KEYDOWN and WM_KEYUP messages, but it looks like Dyalog is only capable of notifying the APL program on the WM_KEYDOWN (via onKeyPress). Is there something I'm missing?
Interestingly, it actually looks like Dyalog may have put in stubs for onKeyDown and onKeyUp, but they don't actually work. The following line actually works without error:
'fm' ⎕WC 'Form' ('Event' 'onKeyPress' 'goo') ('Event' 'onKeyDown' 'goo') ('Event' 'onKeyUp' 'goo')
and you can query those events:
fm.Event
onKeyDown #.goo onKeyUp #.goo onKeyPress #.goo
But:
fm.onKeyDown
VALUE ERROR: Undefined name: onKeyDown
fm.onKeyDown
∧
fm.onKeyUp
VALUE ERROR: Undefined name: onKeyUp
fm.onKeyUp
∧
And, ∇goo (the callback function) is never called with an onKeyDown or onKeyUp event.
And another issue: The event argument when the callback function is called for onKeyPress doesn't include an indicator of whether the key is being repeated. Again, I've figured a way to determine that, but again it's inefficient. I know that information is available somewhere since APL+Win's onKeyPress event argument does include that piece of information. Again, am I missing something?
Thanks for any tips. / Rav
Interestingly, it actually looks like Dyalog may have put in stubs for onKeyDown and onKeyUp, but they don't actually work. The following line actually works without error:
'fm' ⎕WC 'Form' ('Event' 'onKeyPress' 'goo') ('Event' 'onKeyDown' 'goo') ('Event' 'onKeyUp' 'goo')
and you can query those events:
fm.Event
onKeyDown #.goo onKeyUp #.goo onKeyPress #.goo
But:
fm.onKeyDown
VALUE ERROR: Undefined name: onKeyDown
fm.onKeyDown
∧
fm.onKeyUp
VALUE ERROR: Undefined name: onKeyUp
fm.onKeyUp
∧
And, ∇goo (the callback function) is never called with an onKeyDown or onKeyUp event.
And another issue: The event argument when the callback function is called for onKeyPress doesn't include an indicator of whether the key is being repeated. Again, I've figured a way to determine that, but again it's inefficient. I know that information is available somewhere since APL+Win's onKeyPress event argument does include that piece of information. Again, am I missing something?
Thanks for any tips. / Rav
- Rav
- Posts: 22
- Joined: Tue Jul 25, 2023 4:41 pm
Re: onKeyPress but no onKeyDown or onKeyUp
Hello Rav,
I'm afraid that you are not missing anything. Dyalog only generates the KeyPress event. You will have to use ⎕NA to determine any additional information.
Bet Regards
John Daintree
I'm afraid that you are not missing anything. Dyalog only generates the KeyPress event. You will have to use ⎕NA to determine any additional information.
Bet Regards
John Daintree
-
JohnD|Dyalog - Posts: 74
- Joined: Wed Oct 01, 2008 9:35 am
Re: onKeyPress but no onKeyDown or onKeyUp
OK, thank you, John. / Rav
- Rav
- Posts: 22
- Joined: Tue Jul 25, 2023 4:41 pm
3 posts
• Page 1 of 1
Return to Windows: GUI, COM/OLE/ActiveX
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group