Unable to enter cyrillic symbols with software keyboard


#1

Hi!
I noticed another bug on Android.
I created a component with some child TextEditors. I tried to enter cyrillic text into the TextEditor via software keyboard but no symbols were entered. Other characters (with character code less than 128) can be inserted without a problem.
I tried various software keyboards (default Android keyboard, Samsung keyboard, “Hacker’s keyboard”), but none of them worked.

JUCE version I used: 3.0.1
Android version: 4.1.1

Steps to reproduce the bug

  1. Build Juce Demo application for Android, run it / install the apk.
  2. Open Juce Demo app, navigate to “Components: Tabs & Widgets” -> “Misc” tab.
  3. Switch your software keyboard to English language.
  4. Try to enter some text to “Single-line text box”, the text you enter should appear in the TextEditor.
  5. Now switch your software keyboard to Russian language.
  6. Try to enter some cyrillic text to the same TextEditor. No characters will be inserted.

I have a dirty fix for this bug.
In the Java code:

       @Override
        public boolean onKeyDown (int keyCode, KeyEvent event)
        {
            switch (keyCode)
            {
                case KeyEvent.KEYCODE_VOLUME_UP:
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                    return super.onKeyDown (keyCode, event);
                default: break;
            }
            return true;
        }
        @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
        	int kc = event.getUnicodeChar();
        	if (event.getCharacters() != null && kc == 0)
        	{
        		String chars = event.getCharacters();
        		kc = chars.charAt(0);
        	}
        	else if (event.getAction() != KeyEvent.ACTION_DOWN)
        	{
        		return true;
        	}
        	handleKeyDown (host, event.getKeyCode(), kc);
            return true;
        }
        @Override
        public boolean onKeyUp (int keyCode, KeyEvent event)
        {
            return true;
        }

#2

This sounds really complicated. You can also just typ the text you want into a online russian keyboard like http://russtype.com which transform the latin letters into cyrill ones and copy this written text into the TextEditor.