Two text boxes (possible???)

Started by alexhans, Mon 20/02/2006 21:44:58

Previous topic - Next topic

alexhans

Testing with AGS Ive found myself in a strange situation, I wanted to implement the possibility of having two text boxes enabled and the option to write in one of them but always wrote in both.

Is it possible in any way to could click in the one you wish to write leaving the other still visible...?  and then normally ending the first one you would be able to choose the second one and write over it having the two text boxes displayed?

Or... I thought about other possibilities but they seem far too complicated. (Yes! even more)

Ill tell you how this came in to my mind:

I wanted to make a World Cup Fixture with the possibility to enter your own scores as to guess its possible outcomes (Im experimenting in order to undestand more capabilities of AGS) and I discovered you cannot use textboxes like in Microsoft's Excel (With wich, by the way, I made a fixture with its functions).  I could make the player write one result in one GUI, hide it, pop up the other, make the player write the second score, and then display a third GUI with labels but It would be endless scripting (there are more than 80 matches) boring and linear.

So... you guys that are old (in AGS usage of course) to know better, tell me what do you think (even if its for curiosity`s sake)   ::)

Alexhans

Never let your sense of morals prevent you from doing what is right.

Ashen

It's certainly possible to enable and disable TextBoxes. Something like this should work:

You have a GUI (gText) with two TextBoxes (txtText1 and txtText2). Turn the GUI on:
Code: ags

txtText2.Enabled =  false;
gText.Visible = true;


And anything you type will be captured by txtText1 ONLY. Then have this in txtText1's control function:
Code: ags

  // Whatever you want to do with the text (set a label, store it for later, etc).
  txtText1.Enabled = false;
  txtText2.Enabled = true;

And now whatever you type will go to txtText2.

I don't quite follow what you want it for so I can't be more specific, sorry.
I know what you're thinking ... Don't think that.

alexhans

Thanks, thats what I need (I think)

Ill try it out and let you know how it went (with a better explanation too)
Never let your sense of morals prevent you from doing what is right.

alexhans

Well, That finally made it out...

I had another problem:Ã,  I couldnt enable the Textbox1 (for example) by clicking on it because it is not a button so I finally placed a button at the side of it.

- It is possible to do what I said? or are buttons the only clickable things in the GUIs (except the sliding bars and the GUIs themselves)?
-Ã,  Is it possible to place a button in the exact place of the textbox? like this?:

Code: ags

// I have txtbox1 and Button1 and this goes on Button1 activate function
Button1.Visible = false;
Button1.Enabled= false;Ã,  Ã, // I dont remember if I have to do this or not.
txtbox1.Enabled = true;
// Or maybe making the txtbox1 visible AFTER clicking the Button1
txtbox1.Visible = true;


Then I would close the textbox in the interface click section, hold the information in aÃ,  string and Disable again the textbox and its visibility.Ã,  Ã, Then make the button functional again.

Well, I dont take more of your time.Ã,  Thanks.
Never let your sense of morals prevent you from doing what is right.

Scorpiorus

Yeah, you can make a use of buttons, as you describe or possibly handle clicks over textboxes within the on_event() function, something like this:

function on_event (EventType event, int data) {

   // when a mouse button is pressed down over a GUI
   if (event == eEventGUIMouseDown)
   {
      if (gui[data] == gTextgui) // <-- remove it to effect an arbitrary GUI
      {
         GUI *theGui = gui[data];
         
         TextBox *theTextbox = null;
         GUIControl *control = GUIControl.GetAtScreenXY( mouse.x, mouse.y );
         if (control) theTextbox = control.AsTextBox;
         
         if (theTextbox)
         {
            // disable GUI textboxes
            int i = 0;
            while (i < theGui.ControlCount)
            {
               if (theGui.Controls.AsTextBox)
               {
                  theGui.Controls.AsTextBox.Enabled = false;
               }
               
               i++;
            }
            
            // but enable the selected one:
            theTextbox.Enabled = true;

         }
      
      }
      
   }
   
}

SMF spam blocked by CleanTalk