onKeyPress but no onKeyDown or onKeyUp

Using (or providing) components based on the "Win32" framework

onKeyPress but no onKeyDown or onKeyUp

Postby Rav on Thu Jan 11, 2024 7:31 pm

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
Rav
 
Posts: 31
Joined: Tue Jul 25, 2023 4:41 pm

Re: onKeyPress but no onKeyDown or onKeyUp

Postby JohnD|Dyalog on Mon Jan 15, 2024 2:01 pm

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
User avatar
JohnD|Dyalog
 
Posts: 74
Joined: Wed Oct 01, 2008 9:35 am

Re: onKeyPress but no onKeyDown or onKeyUp

Postby Rav on Mon Jan 15, 2024 2:28 pm

OK, thank you, John. / Rav
Rav
 
Posts: 31
Joined: Tue Jul 25, 2023 4:41 pm


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: Google [Bot] and 0 guests