Game Development Community

Text input handling

by Alex Scarborough · in Torque Game Engine · 03/28/2006 (8:49 pm) · 1 replies

After some head banging with guiMLTextEditCtrl, I figured out that certain keys, such as delete, backspace, the movement keys, etc. were triggering both their proper actions and the standard text input stuff. The root of the problem is that when a key is pressed, both DoAppCarbonEventHandling and DoTextInputCarbonEventHandling are called (both in macCarbWindow.cc). DoAppCarbonEventHandling properly passes in the key press as a special key, and not a standard ASCII character. DoTexInputCarbonEventHandling, however, does treat this keys as standard ASCII input, which throws guiMLTextEditCtrl.

Fix: in guiMLTextEditCtrl, around line 172, you should see
if (event.ascii != 0)
. Replace that with
if (mProfile->mFont->isValidChar( event.ascii))
This doesn't solve the actual "bug", but it does make it far less annoying, and probably should be in here anyways. It's how the standard single line text edit gui handles the issue.

#1
04/17/2006 (4:20 pm)
The actual bug is solved by some new event handling code, that will be released soon.