IME Input not working when TextEditor is on desktop

I originally posted this to the Windows part of the forum, but just recognized that this function is used on OS X and iOS as well.

-------

 

When using Microsoft IME to enter e.g. japanese text, JUCE uses the function ComponentPeer::findCurrentTextInputTarget() to find out where to write that text.

That function checks if the ComponentPeer is a parent of the currently focused component. Otherwise it returns a nullptr.

When putting a TextEditor to the desktop, it has no parent, so that check will always fail. I am often putting a TextEditor to the desktop to make sure that all keyboard input is passed to the TextEditor and not processed by the DAW.

I would like to propose the following modification in juce_ComponentPeer.cpp:

Instead of

TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
{
    Component* const c = Component::getCurrentlyFocusedComponent();

    if (component.isParentOf (c))
        if (TextInputTarget* const ti = dynamic_cast<TextInputTarget*> (c))
            if (ti->isTextInputActive())
                return ti;

    return nullptr;
}

it should be

TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
{
    Component* const c = Component::getCurrentlyFocusedComponent();

    if (component.isParentOf (c) || (&component == c))
        if (TextInputTarget* const ti = dynamic_cast <TextInputTarget*> (c))
            if (ti->isTextInputActive())
                return ti;

    return nullptr;
}

Then the TextEditor will also accept IME input when it is on the desktop.

 

What do you think?

 

Regards,

Gregor

Yes, good idea, thanks! That's in there now.