I’m trying to create user text input dialog. I put a text object and connect a keyboard (all keys) sensor to its python handler.
I could manage to get keypresses written (appended) to the text object. Here is the python handler code:
import bge c = bge.logic.getCurrentController() t = c.owner kb = c.sensors["Keyboard"] key = kb.events press = kb.events == 1 release = kb.events == 3 key = chr(key) if press: t.text += key print("key pressed: %s" % (key,))
Problem 1: Unicode characters could not be displayed:
1.1: If you try to write to the text object in edit mode for example “çalış öğün”, “çal öün” is written. What happens to the other characters?
1.2: if you wrote “çalış öğün” to the text object and “çal öün” is written on the display, press P to start game engine, there is “çalış öğün” is written on the display.
1.2: If you try to write the same example text in game mode, the python handler could not get many unicode characters’ and special characters’ events (like çışöğü@`#´µû€âû™+ etc…)
Problem 2: If you write too fast, it is not being recongized by event generator (the sensor).
How could I solve these problems?