How to display a text box content into a label in a GUI ? (SOLVED)

Started by Marion, Fri 04/08/2006 10:49:37

Previous topic - Next topic

Marion

Hi everybody.
I have read the manuel but did'nt find any answer (and as I'm french, it's quite hard to me to understand everything).
I would like to let the player enter a name for his character, and I have created a GUI with a text box.
Now I want to display the name in another GUI label.
But I can't find the code to get the text box content and put it in the label.
Can you help me please ?  ???

Ashen

It depends a little on what version of AGS you're using, since the commands have had their names changed a few times. For V2.71+ you need to use TextBox.Text and Label.Text, for V2.7 it's TextBox.GetText and Label.SetText, earlier than that use GetTextBoxText and SetLabelText. Hopefully, the appraopriate manual entries will help.
I know what you're thinking ... Don't think that.

Marion

I have the 2.71.631 version.
I have found the Textbox.Text and Label.Text in the manual, but I don't know how to write the code precisely to put the TextboxText in the Label.Text...  :-\
I have tried this :
Code: ags

String charname = TextBox.text ;
LabelText = charname;

... but it does'nt work. I'm not very good in using the script code yet...

Ashen

You need to have given the Label and TextBox script-names in the editor, then you use (name).Text. So, if the TextBox was called MyText and te Label is MyLabel, you'd use:
Code: ags

String charname = MyText.Text;
MyLabel.Text = charname;


Be careful of the capitalisation - MyText.Text will work, MyText.text won't.

Also, unless you're keeping the text for use somewhere else, you should be able to copy it directly, without using the String:
Code: ags

MyLabel.Text = MyText.Text;


But, if you're using this text for a character name, you might want to store it  somewhere else as well (like to the Character.Name property, e.g. cEgo.Name = MyText.Text;).
I know what you're thinking ... Don't think that.

Marion

Thank you very much, I'll try :)

Edit : It works ! Thank you very much. I'm too stupid ^^  :P

SMF spam blocked by CleanTalk