Author Topic: GUI Help  (Read 3623 times)

Oh! Silly me! I copied and pasted, but forgot to change it!  :cookieMonster:

When you create a text edit control, you should give it a specific name, such as myTextInput for example
Then to read what people have written in the text box, you do this

Code: [Select]
%input = myTextInput.getValue();
I put
Code: [Select]
%input = myTextInput.getValue();
on the text boxes and I also put AddText1 = $add1.getvalue(); on it. It doesn't work.

(I want the variable to be $add1 and the textcmd name to be AddText1)

You got it flipped around.
You want to set the variable to the value of what is in the text box.

Right now you are trying to set the object to the value of the variable, which well probably give you an error.

You want
$var = object.getvalue();

Ok every time I put something into the text box i crash. This is what I have in the text box thing.

Code: [Select]
%input = addinput1.getValue();$add1 = addinput1.getvalue();


Anybody?  :panda:
First of all, what is the "text box thing".
I can only think that you are using a local % variable in a global context (outside a function). Can you post a console.log of your crash?


This is whats on the box where ppl can put text in.

Code: [Select]
     new GuiTextEditCtrl() {
         profile = "GuiTextEditProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "91 93";
         extent = "41 18";
         minExtent = "8 2";
         enabled = "1";
         visible = "1";
         clipToParent = "1";
         command = "%input = addinput1.getValue();$add1 = addinput1.getvalue();";
         maxLength = "255";
         historySize = "0";
         password = "0";
         tabComplete = "0";
         sinkAllKeyEvents = "0";

This is whats on the box where ppl can put text in.

Code: [Select]
     new GuiTextEditCtrl() {
         profile = "GuiTextEditProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "91 93";
         extent = "41 18";
         minExtent = "8 2";
         enabled = "1";
         visible = "1";
         clipToParent = "1";
         command = "%input = addinput1.getValue();$add1 = addinput1.getvalue();";
         maxLength = "255";
         historySize = "0";
         password = "0";
         tabComplete = "0";
         sinkAllKeyEvents = "0";

1 : You can't state a local (%) variable in that global context
2 : You shouldn't use that code in the command box, you should use a button that has a command and in the code you script, you have addinput1.getValue(); in it.

Also your GuiTextEditCtrl isn't actually named addinput1
It has no name at all

the first line should look like this

Code: [Select]
  new GuiTextEditCtrl(addinput1) {

Also your GuiTextEditCtrl isn't actually named addinput1
It has no name at all

the first line should look like this

Code: [Select]
  new GuiTextEditCtrl(addinput1) {

Right, then after that you can do this to get the text input :

Code: [Select]
function Numbers(%this)
{
   %first = addinput1.getValue();
   echo("The user typed in " @ %first @ " in the first text box");
}

So if I typed in "filler" in the textbox then the variable %first would equal "filler" and you can do what you want with it.

Oooh thanks. Ill fix it in a little while and let you know how it went.