Listbox and mouse interactivity

Hi, I was wondering how to permanently save information in a listbox and what code to use to allow the mouse to drag an object.

  So, I have two labels (for 'name' and 'score') and I have a pushbutton to allow the data from the textfields (for 'name' and 'score') to be added to the listbox. However, whenever I stop the program the user's data (name and score) are not saved. Is there a way to save the user's name and score on the listbox, permanently, so that when the program is rerun the name and score written last show?

  Also, I am making a game (that's called mama and has a maze and the user needs to use the mouse to drag the oval to the other oval without touching any of the mazes) what code would I use for the mouse interactivity? (And if you know how to detect the oval and when it touches any of the rectangles it would be helpful, thank you.)

Thank you, in advance.

Just a few suggestions to get you going…

  1. Pick up a good programming book. Doesn’t have to be specifically about Xojo, just get some of the basic concepts such a persistent data and file manipulation.
  2. Work through some of the example projects which came with Xojo. For saving your data, look in the Files folder under examples.
  3. Your maze idea is certainly doable, but detecting when the oval touches rectangles is decidely non-trivial. Work through some basic concepts before accepting such a challenge.
    Good luck. If you have specific questions as you learn, please post. Other users are eager to help when they see that you are trying to learn on your own.

“Pick up a good programming book. Doesn’t have to be specifically about Xojo, just get some of the basic concepts such a persistent data and file manipulation.”

I have tried that, but seeing that my first language isn’t English it’s very hard for me to understand what it means without seeing a visual. Especially to the programming books since there are very sticky situations that you can get stuck in.

“Work through some of the example projects which came with Xojo. For saving your data, look in the Files folder under examples.”

   I did that first part, but don't see anything about saving data in a listbox in the files folder of the examples section.

“Your maze idea is certainly doable, but detecting when the oval touches rectangles is decidely non-trivial. Work through some basic concepts before accepting such a challenge.”

 I did the 2K game, but made it my own, and I wanted to do this as part of my summative in school since we have worked in xojo. 

All in all, thank you for the great advice. I appreciate it greatly.

[quote=177500:@Walideh Sayed]Hi, I was wondering how to permanently save information in a listbox and what code to use to allow the mouse to drag an object.

  So, I have two labels (for 'name' and 'score') and I have a pushbutton to allow the data from the textfields (for 'name' and 'score') to be added to the listbox. However, whenever I stop the program the user's data (name and score) are not saved. Is there a way to save the user's name and score on the listbox, permanently, so that when the program is rerun the name and score written last show?

  Also, I am making a game (that's called mama and has a maze and the user needs to use the mouse to drag the oval to the other oval without touching any of the mazes) what code would I use for the mouse interactivity? (And if you know how to detect the oval and when it touches any of the rectangles it would be helpful, thank you.)

Thank you, in advance.[/quote]

You need to save the content of the ListBox to disk before quitting your program.

You could use a TextOutputStream http://documentation.xojo.com/index.php/TextOutputStream to create the file, then write every cell() http://documentation.xojo.com/index.php/ListBox.Cell and separate columns with Tab chr(9), and rows with endofLine.

You will obtain a tab separated file which you can load with TextInputStream http://documentation.xojo.com/index.php/TextinputStream

After loading, use Split http://documentation.xojo.com/index.php/split to separate columns from the tabs.

You may want to start with the examples in the LR, learn how to save one word, then load it, then practice accessing the content of the listbox with cell(), then practice with split. If you go step by step you should be able to get there.

“You may want to start with the examples in the LR, learn how to save one word, then load it, then practice accessing the content of the listbox with cell(), then practice with split. If you go step by step you should be able to get there.”

What’s an LR?

And thank you, this is very confusing but it will turn out to be helpful at the end. Much gratitude.

Language Reference. documentation.xojo.com

Thank you, Jason King, this helps me by a lot.

All the links I posted are from the LR, the Language Reference.

Thank you (Michel Bujardet) for making that clearer for me, I appreciate it.

I’m having a difficult time remembering how to get the mouse to drag and object…if anyone can give me the code it’d be good. (I’ve done it before, it’s just that I’ve forgotten the code for it. It’s like a test that you study for, after you ace it you forget it.)