Enter on Textbox not triggering Activated script (SOLVED)

Started by GarageGothic, Tue 12/04/2005 16:51:35

Previous topic - Next topic

GarageGothic

Is there some logical reason why some of my textboxes doesn't run their Activate script when the enter key is pressed? One of them works perfectly, but the other two simply don't register the enter key being pressed. I even put a really simply action in their script, just to see if ANYTHING would happen, but not even a simple display-command could be triggered.

They do react to typing and backspace, but pressing enter does nothing, even if their set up to run a script.

Could it have something to do with other text boxes, even though they are on completely different GUIs and aren't visible at the time? The one working is the first text box I set up, if that has anything to do with it.

rich

I have at least two textboxes in my game, (each in a different GUI) and they both work fine.

make sure that in your on_interface_click function, that you have something like this for each:

if (interface == GUI1) {  //where GUI1 has your first textbox
  if (button == 0)  { //make sure that the textbox is in fact GUI Control 0
     //do stuff
  }
}
if (interface == GUI2) { //where GUI1 has your second textbox
  if (button == 1) { //again make sure the textbox is the correct GUI control, here Control 1
   //do stuff
  }
}

If you're using 2.7, I also highly recommend giving your textbox GUI controls Script-O names so you can do stuff like this:

textbox1.GetText(stringbuffer); //wherer textbox1 is what you named the textbox in the GUI Editor

I hope I've helped in someway... if not, post your code and I'll definitely be able to help.
I'm so excited!

GarageGothic

Thanks for the input. I haven't tried using on_interface_click yet. I was aware that you could do it, but in the globalscript it says the function is obsolete. As I've redone my entire GUI with the object based system, I was trying to avoid old script functions.

Posting the code won't do much good, as the part dealing with the activate script was just done by:
1) Naming the textbox
2) Clicking in the Run Script field for the textbox
3) and then double clicking the textbox to open up the script editor on the relevant script.

Then I just entered  Display("Textbox was activated"); or similar in the script to see if it was actually triggered, so that's pretty much the code that's in there. I did the same for all three, and as I said, it works for one of the text boxes, but not for the two others, which seems strange.

Ashen

Does it make any difference if you disable the textboxes, when you turn their GUI's off? (e.g if (TxtBoxOne.OwningGUI.Visible == 0) TxtBoxOne.Enabled = 0;)
It could be that the first one is blocking the others, despite being invisible.
I know what you're thinking ... Don't think that.

GarageGothic

Yes, that was my thought too. I'll go home and try that.

It's strange though that they should still respond to other key presses if the first text box is blocking them.

rich

I'm sorry, I meant to say interface_click, not on_interface_click

I'm pretty sure interface_click is not obsolete. I looked through the help file and couldn't find any alternative for it. It's one of those functions that kind of is built into the globalscript. If in AGS, you click the Script dropdown menu, and select interface_click, it will add it to your script if it's not already there. Then, inside it, you can add the scripting that I wrote earlier. I guarantee it will solve your problem without the hassle of having to figure out the interactions for the text box in the GUI editor.
I'm so excited!

GarageGothic

#6
I solved the problem. It turns out it was caused by a (possible?) gui editor bug in abbreviating long function names.

My textbox names were quite long to begin with ("txtReplaceDescription" was one), and when the editor autocreated the script, the function was abbreviated as "txtReplaceDescription_Activa". However, in the "Run Script" selection, it had been titled "txtReplaceDescription_Activat". So the correct script was never run. This also explains why one textbox, with the shorter name txtSaveDescription, worked while the others didn't.

Thanks for all your help!

By the way, it was all done with object based scripting, not involving interface_click (I'm pretty sure that whatever function was referenced under the textbox activate part in the help file is obsolete in v. 2.7)

SMF spam blocked by CleanTalk