TextField, what am I doing wrong?

[UPDATE: I figured out what I was doing wrong, and indeed, it was brain dead simple.]

This is driving me bananas… I’m sure there’s something simple I’m doing wrong, but I can’t see it, and hope a few more eyes can help. I am unable to enter characters in to a TextField. The cursor appears, and if I put text in the field, I can navigate with arrow keys. I am just unable to enter any characters. I’ve attached a the project. Thanks for any help you can give!

465040–16310–$TestTextField.zip (47 KB)

could you share the code? Im sure people would prefure to see it rather than downloading project, quick question though, have you set maximum characters?

Sure thing, I thought the project might be useful as I was concerned the way I hooked it up to the camera might be incorrect. I have tried setting maximum characters and it didn’t make a difference. Here’s the code, note that both the PasswordField and TextField both exhibit the same problem:

This is the only file, I called it “TestTextField.js”.

function Update () {
}

function OnGUI() 
{
	GUILayout.Window(0, Rect(0,0,200,100), CreateWindow, "Login");
}

function CreateWindow(windowID : int)
{
	var loginName : String;
	var loginPassword: String;

	GUILayout.BeginVertical();	
	
	GUILayout.BeginHorizontal();
	GUILayout.Label("Name");
	loginName = GUILayout.TextField("");
	GUILayout.EndHorizontal();
	
	GUILayout.BeginHorizontal();
	GUILayout.Label("Password");
	loginPassword = GUILayout.PasswordField("", "*"[0]);
	GUILayout.EndHorizontal();
	
	if(GUILayout.Button("Login"))
	{
		print("Login name: " + loginName + " Login password: " + loginPassword);
	}
	
	GUILayout.EndVertical();
}

Sometimes just talking about code (or writing in this case) makes you figure it out! My problem was that I’m thinking in “retained mode” and was initializing the text field with an empty string. In immediate mode this just clears the field, every update. UGH! Simple indeed, but I really need to retrain myself to do this immediate mode stuff. Thanks for looking :slight_smile: