Important:
PLEASE read the post at the very bottom. Many questions asked prior to that are already somewhat answered. But I encounter a very serious problem in the way that android studio doesn’t want to compile changes in the JUCE native android code, which makes it impossible to debug my error! Please someone give me a hint what to do!
As it turns out there is a serious bug in the JUCE native code that prevents us from releasing our app.
We use TextEditors, to handle user input. Unfortunately you can’t dismiss the soft keyboard. If I press the back key, the keyboard disappears for a brief second and pops up again.
There is already code present that should do this. But it doesn’t.
The JNI function handleKeyboardHiddenJni is defined inside juce_android_Windowing.cpp, and assigned to the member function handleKeyboardHiddenCallback. The method is also implemented correctly (as I would have done as well)
void handleKeyboardHiddenCallback()
{
Component::unfocusAllComponents();
}
The function gets called inside ComponentPeerView.java within private final class KeyboardDismissListener where apparently it is detected, whether or not it should hide the keyboard
// Arbitrary threshold, surely keyboard would take more than 20 pix.
if (diff < 20 && keyboardShown)
{
keyboardShown = false;
handleKeyboardHidden (view.host);
}
if (!keyboardShown && diff > 20)
keyboardShown = true;
As I wanted to debug this whole thing, I added a breakpoint to handleKeyboardHiddenCallback() inside juce_android_Windowing.cpp, but the method is never called!
I would handle the keyboard dismiss by myself, but unfortunately, the backButtonPressed() function of juce_ApplicationBase that I have overriden in my Main.cpp (which implements JUCEApplication), is not called when dismissing the keyboard. I have to press the back button twice (once for the keyboard and then for the “application”), for backButtonPressed() to trigger!
I would be so happy about a quick reply with a working fix or workaround as we obviously can’t release our app with this non intuitive and odd behaviour.
Thanks a lot
EDIT 1:
Apparently there are some commits which mention either the keyboard or focusing the TextEditor:
and also a fix for a crash bug I had encountered not too long ago
But all these commits don’t seem to solve the issue I have described, as I tried both with the newest master branch and the newest develop branch.
EDIT 2:
This is really weird. I somehow got it to work once. Also the delay after whichthe keyboard reappears is completely random. Sometimes you don’t even notice it and on some other occasions, you can see it “slide” down and “slide” back up again. I have a slight suspicion, it might have something to do with the arbitrary threshold, which is described in the comment
// Arbitrary threshold, surely keyboard would take more than 20 pix.
if (diff < 20 && keyboardShown)
{
...
the thing I have no clue about is that the keyboard indeed gets dismissed! But just for a brief second before it appears again (except the one time I somehow managed to dispose it).
But in my opinion the keyboard is never even dismissed by JUCE itself (so the handleKeyboardHidden (view.host); is never triggered), because the method handleKeyboardHiddenCallback() is never triggered!
God this makes no sense
