Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: yarooze on Sun 08/12/2024 12:26:26

Title: Multiple text boxes problem
Post by: yarooze on Sun 08/12/2024 12:26:26
Hi!

If I put two text boxes into one GUI they always have the same content. If I fill one of them, another one is filled automatically.

Am I doing something wrong or is this correct behavior?

Tested in AGS 4.0 and AGS 3.6.1 with some script behind the GUI and without.

(https://i.postimg.cc/ppcM9B1L/doubletextboxgui.png) (https://postimg.cc/ppcM9B1L)

Steps to reproduce:
Title: Re: Multiple text boxes problem
Post by: eri0o on Sun 08/12/2024 12:44:27
That is expected, the way it works is you have to disable the textbox you don't want to capture input and enable the ones you want to capture. There isn't anything like focus or selected state in GUI controls.
Title: Re: Multiple text boxes problem
Post by: yarooze on Sun 08/12/2024 13:53:47
Quote from: eri0o on Sun 08/12/2024 12:44:27That is expected, the way it works is you have to disable the textbox you don't want to capture input and enable the ones you want to capture. There isn't anything like focus or selected state in GUI controls.

Ah.. thank you.

Also something like: disable both fields by default, add the buttons "edit1" and "edit2" with enable/diasable script and diasble on text box activate event?

function TextBox2_OnActivate(GUIControl *control)
{
  TextBox2.Enabled = false;
}

function Button2_OnClick(GUIControl *control, MouseButton button)
{
  TextBox1.Enabled = false;
  TextBox2.Enabled = true;
}

function TextBox1_OnActivate(GUIControl *control)
{
  TextBox1.Enabled = false;
}

function Button1_OnClick(GUIControl *control, MouseButton button)
{
  TextBox2.Enabled = false;
  TextBox1.Enabled = true;
}

Title: Re: Multiple text boxes problem
Post by: Snarky on Sun 08/12/2024 14:57:22
Note that there is a module that makes multiple TextBoxes work the way you would expect, with only a single one having focus:

https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-multitextbox-v1-00-handle-multiple-text-boxes/msg636616479/#msg636616479

It's pretty easy to use. There is also my TextField module (https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-textfield-v1-2-0/msg636664629/#msg636664629) that acts as a TextBox replacement and gives you a text cursor (caret) that allows you to edit the text in the middle, use copy-paste, etc. It also has only one TextField having focus at a time.
Title: Re: Multiple text boxes problem
Post by: yarooze on Sun 08/12/2024 15:38:52
Quote from: Snarky on Sun 08/12/2024 14:57:22Note that there is a module that makes multiple TextBoxes work the way you would expect, with only a single one having focus:

https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-multitextbox-v1-00-handle-multiple-text-boxes/msg636616479/#msg636616479

It's pretty easy to use. There is also my TextField module (https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-textfield-v1-2-0/msg636664629/#msg636664629) that acts as a TextBox replacement and gives you a text cursor (caret) that allows you to edit the text in the middle, use copy-paste, etc. It also has only one TextField having focus at a time.

This looks interesting. The cursor would be my another question. Thank you.