Multiple text boxes problem

Started by yarooze, Sun 08/12/2024 12:26:26

Previous topic - Next topic

yarooze

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.



Steps to reproduce:
  • Start new game with sierra-style template
  • add a GUI
  • add two text boxes
  • start the game and fill the text box
My Blog

eri0o

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.

yarooze

#2
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?

Code: ags
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;
}

My Blog

Snarky

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 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.

yarooze

#4
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 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.
My Blog

SMF spam blocked by CleanTalk