I am trying to do my inputbox, instead of Ags default one, but i cant understand a thing.
I've created a new Gui with a TextBox. When i call the gui, i can instantly write on the textgui, but if i press "enter", it doesnt do a thing. I was expenting that, so i scripted in "on_key_press" event, this :
if (IsGUIOn ( 8 )==1){
if (keycode==13){
GUIOff( 8 );
GetTextBoxText (8,0,string);
SetTextBoxText(8,0,"");
}
}
But when the TextBox is up, it ignores the key_press, which is obvious.
So, my question are: can i do my own InputBox, or if i can, where can i script the "press enter" in TextBox to do something?
When a GUI is displayed, pressing enter calls interface_click with the GUI and button number of the text box. So move your code into interface_click and modify it slightly:
if ((interface == YOURGUI) && (button == XXX)) {
GUIOff( 8 );
GetTextBoxText (8,0,string);
SetTextBoxText(8,0,"");
}
where YOURGUI is the GUI name, and XXX is the object number of the text box.
I believe that in the manual it states that:
When a textbox GUI is on, and the enter key is pressed, the script is passed to interface_click. So, all you have to do is:
function interface_click(int interface, int button){
Ã, // stuff
Ã, else if (interface == 8) {
Ã, Ã, if (button == 0) { // If pressed enter / clicked on textbox
Ã, Ã, Ã, GUIOff(8);
Ã, Ã, Ã, GetTextBoxText(8, 0, stringvar);
Ã, Ã, Ã, SetTextBoxText(8, 0, "");
Ã, Ã, Ã, }
Ã, Ã, }
I don't think you can use "string" as the name of a variable, so I changed it to "stringvar", also, it would have to be declared before your interface_click function. Presuming that you have a reason for remembering what text was on the label at the time enter was pressed. Otherwise that line can just be deleted...
Thanks! I've discovered it myself just right now.
I am very sorry, but it's not the first time this happens.
I spent , like, one hour, searching in the help file for something, and i cant find it.
I decide to post here, and when i post, i continue searching and i find it whitin 1m after posting. I hate when this happens.
Thanks again, and sorry for the post :P
And yes, the name i've given to string was nome_save, and 'SetTextBoxText(8, 0, "");' was just a stupid test ^^, but thanks.