No GetChar() on XT9 Smartphones! Bug?

Monkey Targets Forums/Android/No GetChar() on XT9 Smartphones! Bug?

Midimaster(Posted 2013) [#1]
some of my users tell men, that my ingame function of enter players name does not work. On my test devices it works always perfect.

Now we did some test and found out, that if "XT9 Predictive Text" is active, the monkey function does not return anything.

Demonstration code:

Monkey V71
Strict
Import mojo

Class Game Extends App

	Field Input$, LastChar%

	Method OnCreate%()
		SetUpdateRate 10
		Return 0
	End	


	Method OnUpdate%()
		If KeyHit(KEY_ESCAPE) OnBack()
		If TouchHit(0) 
			EnableKeyboard()			
		Endif

		TextEingabe
		Return 0
	End	


	Method OnRender%()
		Cls
		DrawText Millisecs(),30,30
		MalTextEingabe
		Return 0
	End	
	
	
	Method OnBack%()
		EndApp()
		Return 0
	End
	
	
	
	Method MalTextEingabe:Void()
		Local Cursor$

		If Millisecs() Mod 1000<500
			Cursor="_"
		Endif	
		PushMatrix
			Translate 250,50
			Scale 1.75,2
			SetColor 255,255,255
			DrawText Input + Cursor, 0,0
		PopMatrix
	End



	
	Method TextEingabe:Void()
		LastChar=GetChar()
		If LastChar<> 0
			Print "NEW CHAR = !" + LastChar + "!     String= !" + String.FromChar( LastChar ) + "!     Player= !" + Input + "!"
	      If LastChar>=32
				Input=Input + String.FromChar( LastChar )
			Elseif LastChar=CHAR_BACKSPACE
				If Input.Length()>0
					Input=Input[..-1]
				Endif
	      Elseif LastChar=CHAR_ENTER
				DisableKeyboard()
			Endif
		Endif
	End
End


Function Main%()
	New Game
	Return 0
End


Is this a bug? Is there another way to get the keys?


Paul - Taiphoz(Posted 2013) [#2]
at a glance, if monkey is looking for a key press to get the character, but the device predictive text inserts a character itself bypassing the key press call which monkey is waiting for then your code wont get those predicted characters.

that's a guess, but would explain why you get no return.


Midimaster(Posted 2013) [#3]
I'm not talking about predicted characters... I don't get any character nor any key press!

I get all key presses from number keys and also the RETURN is ariving. But in a chain of alphabetic characters "A" - "Z" I get nothing imediately. but when I press a number I get the first alpha character and the last number in two GetChars()... Strange!

I think this is a fundamental problem and relevant for all of us, if ask for user input words in games.