Note about Ctrl+A/Z: AFAIU, it's what the console app were expected in the ages, so our OS still carry this tribute to legacy...
See how we have to workaround on linux:
https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/abf05549bd377106f27600a293d79f75a59e705e/platforms/unix/vm-display-X11/sqUnixX11.c#L2065
Who is turning the keysym into 1 to: 26 charCode?
https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/abf05549bd377106f27600a293d79f75a59e705e/platforms/unix/vm-display-X11/sqUnixX11.c#L2049
See https://linux.die.net/man/3/xlookupstring
I also mentionned this in issue #396
So we might want to do something similar on Windows? (and Mac OS?)
For Win32, see https://docs.microsoft.com/en-us/windows/win32/learnwin32/keyboard-input
MSDN page above explicitely explains that CTRL+A/Z are translated to ASCII control character in the VM_CHAR
event (as I suggested in preliminary comment, for legacy console app).
It also does not recommend handling CTRL+... or ALT+... thru WM_CHAR
event, this is not the idiomatic handling on this platform.
And the doc is right - see why below.
The equivalent of linux keysym is the virtual key code (VK_*
) passed thru wParam in WM_KEYDOWN
event.
https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/d58235ca011b9a8f8344814b66d9f9d6428c963f/platforms/win32/vm/sqWin32Window.c#L1262
The problem is that we effectively get the keycode in case of WM_KEYDOWN
event, but not in case of VM_CHAR
event: msg->wParam
holds an UTF-16 Unicode character the doc says...
So, IMO, we should better generate an extra OpenSmalltalk EventKeyChar
event in response to WM_KEYDOWN
event when we detect a CTRL down status, and filter out the event in case of VM_CHAR
with CRTL down...
Note that Pharo VM uses MapVirtualKey
with MAPVK_VSC_TO_VK
to handle ctrl+char
https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/d58235ca011b9a8f8344814b66d9f9d6428c963f/platforms/win32/vm/sqWin32Window.c#L1319
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mapvirtualkeya
Though it's not clear where the usage of msg->lParam
comes from (MapVirtualKey
expects a scan code, which is low level keyboard code and will return a VK code that fortunately matches ASCII for A to Z keys...), I've not seen it documented in official MSDN, it would be good to have a link documenting it.
It's not the way that MSDN (and I) recommended above, but might eventually work (I'm not in a position to understand if there are other side effects...)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/42?email_source=notifications\u0026email_token=AIJPEW5YFD4NYNFYWELN4UTQYQIZDA5CNFSM4CNBGDSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG3QVBA#issuecomment-565643908",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/42?email_source=notifications\u0026email_token=AIJPEW5YFD4NYNFYWELN4UTQYQIZDA5CNFSM4CNBGDSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG3QVBA#issuecomment-565643908",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>