We recently got some feedback from our Japanese users: IMEs do not respond in a text input dialog despite working perfectly fine in our app’s main window. The dialog is basically an AlertWindow with a TextEditor added to desktop after calling enterModalState.
I tried removing enterModalState from the dialog spawning code and was able to regain IME support. I looked into JUCE library code for anything that both has to do with key presses and component modal state and found this line in HWNDComponentPeer::doKeyDown() very fishy.
So this means a key down event gets consumed if any component is made modal, even if the event is on the modal component. I tried removing this condition, shortening this line to return used; and this seems to solve the problem. The question is: are there any side-effects? Did I just fixed a bug or broke a bunch of things as well?
Update
This problem only occurs when running as a VST plugin. It does not affect the standalone version.
I also propose the following fix just to be cautious of breaking anything.
if (auto modalComponent = Component::getCurrentlyModalComponent())
{
// Consume the event if it's sent to a non-modal ComponentPeer.
if (modalComponent -> getPeer() != this)
return true;
}
return used;
I have a similar issue described above.
I created an empty plugin project and placed a TextEditor and an editable Label on the UI. If it was loaded as VST3 plugin, they didn’t work, but launching it as standalone both worked and the IME suggestions came up.
I experimented a bit around it and my finding is the following:
bool TextEditor::keyStateChanged (const bool isKeyDown)
{
if (! isKeyDown)
return false;
#if JUCE_WINDOWS
if (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0).isCurrentlyDown())
return false; // We need to explicitly allow alt-F4 to pass through on Windows
#endif
if ((! consumeEscAndReturnKeys)
&& (KeyPress (KeyPress::escapeKey).isCurrentlyDown()
|| KeyPress (KeyPress::returnKey).isCurrentlyDown()))
return false;
// (overridden to avoid forwarding key events to the parent)
return ! ModifierKeys::currentModifiers.isCommandDown();
}
If I replace the last return with return false then the IME works with TextEditor but not with Label.
I’m not suggesting this is a valid fix at all, but maybe could it be a hint?