iOS virtual keyboard issues

I see that this has been asked in the past, but as far as I can see, no one ever really figured it out.

On iOS, if you have a TextEditor component “too low” on the screen, when it gains focus the virtual keyboard comes up but it covers the TextEditor. In other iOS apps, the entire UI will kind of shift to make the text input UI visible as you type.

Is this something that should be the responsibility of JUCE? To keep a TextEditor visible while typing into it? If it’s the responsibility of the app instead, has anyone figured out how to detect the appearance of the virtual keyboard, and how to shift the entire app’s UI to keep a TextEditor visible?

We ran into this issue as well. We’re moving the whole UI as soon as a text editor becomes active using an affine transform such that the text editor that is active is about 1/4th down from the top. When the text editor is closed, we reset the transform.

I’d be curious to know about other approaches that people have come up with.

In other frameworks this approach has been necessary because the IME/Text editing features of the native platform (both Android and iOS) have been implemented by having an actually native TextEdit field included in the native client build, but have it ‘invisible’ by putting it off the screen, while trapping events with listeners which then get processed by the framework. This native TextEditor is usually positioned, geometry-wise, far, far off the end of the screen so that - even when it has focus - it is not visible. This has the side-effect of altering the geometry when an IME keyboard is to be shown in the native framework.

I don’t know if this technique is used in JUCE - haven’t drilled into it - but don’t be surprised if, by transforming the views, you suddenly see a strange previously-unknown textedit field appear - this is the ‘ghost’ text edit field, if this technique (which is quite common in cross-platform frameworks) is being used …

1 Like

What’s your technique for knowing when the onscreen keyboard appears? Since the user could also be using an actual hardware keyboard, watching for text field focus wouldn’t necessarily do the right thing.

We’re simply using a focuschangelistener and detect if the component that has focus is a text editor or not…

Does that work if the user has a hardware keyboard? (Without unnecessarily shifting the UI in that case.)

I believe you can detect the presence of the on-screen keyboard with objective C or Swift code if you’re on iOS. We’re not using this because we do more adaptations for text editors other than just moving them around for visibility, that we also want with hardware keyboards on iOS.