Game Development Community

Help with GuiTextEditCtrl

by RollerJesus · in Torque Game Builder · 06/30/2008 (10:31 am) · 2 replies

I'm making an adventure game inspired by the Sierra classics (King's Quest and Quest for Glory in particular) and am working on the text input GUI.

Currently I have it setup where all the letter keys are mapped to a function that sets a GuiTextEditCtrl (an element of the playScreen.gui) to visible, passes it the letter that was pressed, clears the contents and sets its value to the pressed letter and sets it as a first responder so the cursor is active and ready to accept input. Upon pressing enter, a parseText function is called on the text in the box and it is set to be invisible again.

However, the cursor ends up to the left of the letter that was passed and set as the value...

My goal is to have the letter that was pressed to activate the GuiTextEditCtrl field appear and have the cursor to the right of that letter, ready to accept further input but I can't get this to work.

Does anyone have any insight into this issue?

EDIT: figured out how to pass the letter, duh...

#1
08/10/2008 (10:26 pm)
There's a setCursorPosition() method in the GuiTextEditCtrl. Have you tried this?

The method states:
Use the setCursorPos method to set the current position of text cursor to newPos. If the requested position is beyond the end of text, the cursor will be placed after the last letter. If the value is less than zero, the cursor will be placed at the front of the entry. The passed in parameter is the new position to place the cursor at, where 0 is at the beginning of the line, 1 is after the first letter, and so on.

Hope this helps!
#2
08/11/2008 (5:54 am)
Sounds like that's the ticket, I'll try it when I get home.

Thanks!

'Patrick

EDIT: Worked like a charm, thanks!