GUI Listbox/Textbox woes (Solved!)

Started by BerserkerTails, Mon 27/06/2005 08:15:23

Previous topic - Next topic

BerserkerTails

Okay, so what I'm trying to do is code a Save-Game GUI. I want it so that when the player selects a save game from the listbox to overwrite it, it automatically fills in the textbox with the name of that saved game. I've put this command in:

Code: ags
ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);


Where 5 is the Save Gui, and 4 is the Listbox. So now, the name of the selected game is in the string "savbuf". Is there anyway now, to get the textbox to display that string? I've tried the SetTextBoxText function, but it only seems to want to input specific text, and not recall a string.

Any help would be appreciated, thanks!
I make music.

Gilbert

SetTextBoxText() works for me, is it possible that there're some other codes interfering with it?

BerserkerTails

I don't think so. The problem I'm having is not knowing how to get SetTextBoxText() to recall the string "savebuf". I can get it to work if I tell it to set the text as something specific, such as "Save Game 1", but can't get it to set the text to a string.
I make music.

Gilbert

Just use something like:
SetTextBoxText(2,3,savebuf);

Trust me, it will work as I had done the same stuff already.

BerserkerTails

Thanks Gilbot, for some reason it worked when I tried it this time. I could've swore I tried that before... Oh well.

Now when you open up the Save game menu, it automatically selects the latest saved game and puts it's name in the textbox, making it easy to overwrite.

One more question though. How can I get it to get the name of other saved games when they're highlighted to be put into the textbox? For example if you want to overwrite an older saved game, how can I get the name of that older saved game to appear in the textbox when it's selected?
I make music.

Gilbert

Quote from: BerserkerTails on Mon 27/06/2005 17:46:23
One more question though. How can I get it to get the name of other saved games when they're highlighted to be put into the textbox? For example if you want to overwrite an older saved game, how can I get the name of that older saved game to appear in the textbox when it's selected?

Just put in on_mouse_click() to check if the listbox was clicked (maybe there're alternative ways with V2.7+), if it was clicked, just like you had mentioned, use:
ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
to get the name and then SetTextBoxText() again.

BerserkerTails

Okay, call me a complete noob, but I ave no clue how to use the on_mouse_click() function. The help file doesn't really tell me much on how it's used, so I'm kinda clueless. I put this:

Code: ags
      if (on_mouse_click (LEFT)) {
        ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
        SetTextBoxText (5,1,savbuf); }


It doesn't seem to be working though. Could you perhaps tell me what I'm doing wrong?
I make music.

Gilbert

I wrote it wrongly, it should better be in interface_click(), which should be already there inside your global script, add inside several lines, like:
function interface_click(int interface, int button) {
//blahblahblargh

  if (interface==5){ //Savegame GUI
    if (button==4) { //Clicked listbox
      ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
      SetTextBoxText(whatever appropiate parameters);
    }
  }

}

BerserkerTails

Gilbot, you're amazing. Thanks so much, I've FINALLY got my Save/Load GUIs working properly.
I make music.

SMF spam blocked by CleanTalk