GUITextEdit example, OR best way to get text entry?
by Brian Carter · in Torque X 2D · 01/11/2010 (11:23 am) · 1 replies
First off, I'm new to TorqueX but not so much to XNA. Still poking around trying to work stuff out and I'm fine with everything in the tutorials, except there is a HUGE lack of GUI documentation and examples.
I'm messing around with the TorqueX GUI 2D starter, and I want a text edit field (GUITextEdit?) to appear on a screen, have it size a font to match the resolution and retrieve input from it. Does anybody have a quick example to get me going.
I can't be the only one wanting to obtain text data entry within a game, can I? Why is there such a void in GUI examples and documentation?
Tried the following code in the GUIMainMenu.cs of the starter project:
namespace StarterGame2D
{
class GuiMainMenu : GUIBitmap, IGUIScreen
{
public GuiMainMenu()
{
// Turn on the mouse;
Game.Instance.IsMouseVisible = true;
... blah blah all the button code etc...
GUITextStyle editStyle = new GUITextStyle();
editStyle.FontType = "arial16";
editStyle.TextColor[0] = Color.Red;
editStyle.SizeToText = true;
editStyle.BorderColor[0] = Color.Red;
GUITextEdit myEdit = new GUITextEdit();
myEdit.Style = editStyle;
myEdit.Text = "Test";
myEdit.Position = new Vector2(20, 30);
myEdit.Size = new Vector2(300, 30);
myEdit.Active = true;
myEdit.Visible = true;
myEdit.Folder = this;
myEdit.FocusOnWake = true;
//setup the input map
SetupInputMap();
}
.. blah blah rest of code in the file
It shows the red "Text" in the right place at the right position, but it won't allow me to edit. Anybody have any pointers as to what else I need to do here?
I'm messing around with the TorqueX GUI 2D starter, and I want a text edit field (GUITextEdit?) to appear on a screen, have it size a font to match the resolution and retrieve input from it. Does anybody have a quick example to get me going.
I can't be the only one wanting to obtain text data entry within a game, can I? Why is there such a void in GUI examples and documentation?
Tried the following code in the GUIMainMenu.cs of the starter project:
namespace StarterGame2D
{
class GuiMainMenu : GUIBitmap, IGUIScreen
{
public GuiMainMenu()
{
// Turn on the mouse;
Game.Instance.IsMouseVisible = true;
... blah blah all the button code etc...
GUITextStyle editStyle = new GUITextStyle();
editStyle.FontType = "arial16";
editStyle.TextColor[0] = Color.Red;
editStyle.SizeToText = true;
editStyle.BorderColor[0] = Color.Red;
GUITextEdit myEdit = new GUITextEdit();
myEdit.Style = editStyle;
myEdit.Text = "Test";
myEdit.Position = new Vector2(20, 30);
myEdit.Size = new Vector2(300, 30);
myEdit.Active = true;
myEdit.Visible = true;
myEdit.Folder = this;
myEdit.FocusOnWake = true;
//setup the input map
SetupInputMap();
}
.. blah blah rest of code in the file
It shows the red "Text" in the right place at the right position, but it won't allow me to edit. Anybody have any pointers as to what else I need to do here?
Torque Owner Brian Carter