Hopefully I can make sense with my findings...
Below is a table of tests and results. Also included are the call stacks showing the chain of command for each of WM_CHAR and WM_KEYDOWN.
It would seem that the new window doesn't receive WM_CHAR to follow up the WM_KEYDOWN. WM_CHAR only happens when the key corresponds to an ASCII character. It would be wrong of JUCE to rely on this alone, and it doesn't. During the WM_KEYDOWN, JUCE calls PeekMessage to see if there's a WM_CHAR in the queue. If there is, it assumes it will handle the key press during the WM_CHAR message. If not, it maps the key to a character and registers the keypress.
- Code: Select all
if (! PeekMessage (&msg, hwnd, WM_CHAR, WM_DEADCHAR, PM_NOREMOVE))
{
// if there isn't a WM_CHAR or WM_DEADCHAR message pending, we need to
// manually generate the key-press event that matches this key-down.
const UINT keyChar = MapVirtualKey ((UINT) key, 2);
used = handleKeyPress ((int) LOWORD (keyChar), 0) || used;
}
The problem is that although PeekMessage returns true in every test, in the Bidule cases it never receives the WM_CHAR that is promised.
Tests
- Code: Select all
Bidule
VST window
'a' key: WM_KEYDOWN(value 65), WM_CHAR(value 97, param 1966081)
left arrow key: WM_KEYDOWN(value 37)
New window
'a' key: WM_KEYDOWN(value 65)
left arrow key: WM_KEYDOWN(value 37)
Reaper
VST window
'a' key: WM_KEYDOWN(value 65), WM_CHAR(value 97, param 1966081)
left arrow key: WM_KEYDOWN(value 37)
New window
'a' key: WM_KEYDOWN(value 65), WM_CHAR(value 97, param 1966081)
left arrow key: WM_KEYDOWN(value 37)
Call Stacks- Code: Select all
WM_KEYDOWN
> JuceDemoPlugin.dll!juce::TextEditor::keyStateChanged(const bool isKeyDown=true) Line 2091 C++
JuceDemoPlugin.dll!juce::ComponentPeer::handleKeyUpOrDown(const bool isKeyDown=true) Line 228 + 0x12 bytes C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::doKeyDown(const unsigned int key=51) Line 1849 + 0xa bytes C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x000407ba, unsigned int message=256, unsigned int wParam=51, long lParam=262145) Line 2221 + 0xc bytes C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x000407ba, unsigned int message=256, unsigned int wParam=51, long lParam=262145) Line 2102 + 0x18 bytes C++
WM_CHAR
> JuceDemoPlugin.dll!juce::TextEditor::keyPressed(const juce::KeyPress & key={...}) Line 2086 C++
JuceDemoPlugin.dll!juce::ComponentPeer::handleKeyPress(const int keyCode=65, const unsigned int textCharacter=97) Line 180 + 0x11 bytes C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::doKeyChar(int key=65, const long flags=1966081) Line 1915 C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x000407ba, unsigned int message=258, unsigned int wParam=97, long lParam=1966081) Line 2236 + 0x10 bytes C++
JuceDemoPlugin.dll!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x000407ba, unsigned int message=258, unsigned int wParam=97, long lParam=1966081) Line 2102 + 0x18 bytes C++