How Do I Save/Load Written Text In A Textbox So All Can See?

  • How you want to organize and load your keys is up for you to decide. The first step is to determine exactly what you want to do, then you will be able to ask specific questions about how to do specific things. If you are not specific, people are much less likely to help you. It is not easy to give advice to do "something".

    To display a key, use the Dictionary.Get("key") expression. For example,

    On Trigger -> Text Set text to Dictionary.Get("input_Name").

    This will set the text object to whatever was saved in the dictionary under the input_Name key.

    To add all keys to a listbox,

    On Trigger

    Dictionary For Each Key -> List Add item Dictionary.CurrentKey

    To use the list to select a key,

    List On Selection Changed -> Text Set text to Dictionary.Get(List.SelectedText)

  • Hey Thanks, and sry for being so vague in my language. I did what you told me to do, but I still have a problem with the list. Could you look at it? Also, I'm not sure how to create a new key. It seems to be saving only one key/message... the very last key/message made.

    https://www.dropbox.com/s/xko3jsbwvm0w5 ... .capx?dl=0 (THIS LINK IS OLD)

  • Hey oosyrag I've been trying to get it to work with a save button, but I'm still having a bit of a problem. (This capx is an updated capx). https://www.dropbox.com/s/7ypyehb6m18y9 ... .capx?dl=0

  • On the left textbox the user writes the clue. The right textbox the user can read past/saved clues. The save button, saves the messages written in the left textbox to the list. When you click on a specific message/item in the list, it will appear in the right textbox.... Although, I'm having a problem getting the save button to work with the list.

  • Dictionary.CurrentKey only works in a "For each Key" loop. If you aren't in a loop, there is no "current" key.

    So you're still missing how you want to organize and store your entries. Are you going to refer to each entry by time? date? name?

    You shouldn't update a key every time the text is changed, only when you press the save button. When you save, you want it added to a new key.

    Here is an updated capx. Each entry is incremented by 1, based on the number of items in the list, using the list.itemcount expression. You'll want to update the List - add item action to change whatever you want to name your entry.

    https://www.dropbox.com/s/0mmv7nmte4fl1 ... .capx?dl=0

    Also generally you want to avoid the tap gesture, it is not very responsive for UI purposes, it is better to use on touched object or on touch released with an is touching object condition.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Dictionary.CurrentKey only works in a "For each Key" loop. If you aren't in a loop, there is no "current" key.

    So you're still missing how you want to organize and store your entries. Are you going to refer to each entry by time? date? name?

    You shouldn't update a key every time the text is changed, only when you press the save button. When you save, you want it added to a new key.

    Here is an updated capx. Each entry is incremented by 1, based on the number of items in the list, using the list.itemcount expression. You'll want to update the List - add item action to change whatever you want to name your entry.

    https://www.dropbox.com/s/0mmv7nmte4fl1 ... .capx?dl=0

    Also generally you want to avoid the tap gesture, it is not very responsive for UI purposes, it is better to use on touched object or on touch released with an is touching object condition.

    I'd like to refer to each entry by name (but don't know how).

    But wow, that cleared up a lot.

    I added this line: List -> On Clicked -> SavedTextBox -> Set Text to Dictionary.Get(List.SelectedText), and everything worked. So I get how to access the list and past messages now, but I don't now how to refer to each entry by name.

    So now, is it completely saved locally? I ask, because though it saves each session, when I close and reopen in browser, what was stored in the list, is gone/reset.

    Can I now send the entire array or dictionary object as json to a firebase/database key (which all users can access)?

    Updated App: https://www.dropbox.com/s/9zl2hvoocdhk1 ... .capx?dl=0

    ....

    I just want to say Thanks so much btw, for taking the time to help!

  • Currently it is only saved per session. If you want the data to persist between sessions or be shared among multiple users, you will indeed want to save the json data to either localstorage or a web server like firebase.

    To save by name, you'll need to enter a name when saving (another textbox, or automatically based on something else like their login name). You will create the list item with that name, and save the name in the dictionary as the key. When you retrieve it, you will once again refer to the name.

  • Okay, thanks I'll try everything you said, and get back to you.

  • Wow, After a couple of hours, I'm clearly still very confused when it comes to the naming of items on the list. This is what I did so far, but I only ended up destroying my capx, to the point that it doesn't even work anymore, but I'm trying lol... I just don't understand the process yet -- i.e. I feel very dumb right now:(

    Updated version: https://www.dropbox.com/s/bgb8x7gqwr4yt ... .capx?dl=0

  • I have no idea what you're trying to do with the first two events. CData2.json is an array asJSON, and you're trying to load it into a dictionary object.

    https://www.dropbox.com/s/4xm47y1ltmy59 ... .capx?dl=0

    Here is what is happening:

    Create a new list item with the inputted name (EntryName.Text).

    Select the new list item

    Create a dictionary key with the same name as the selected list item (List.SelectedText), with contents from textbox (TripReportTextBox.Text).

    You should probably familiarize yourself with how to use expressions. Everything you are trying to do is very clearly documented in the manual.

  • I have no idea what you're trying to do with the first two events. CData2.json is an array asJSON, and you're trying to load it into a dictionary object.

    https://www.dropbox.com/s/4xm47y1ltmy59 ... .capx?dl=0

    Here is what is happening:

    Create a new list item with the inputted name (EntryName.Text).

    Select the new list item

    Create a dictionary key with the same name as the selected list item (List.SelectedText), with contents from textbox (TripReportTextBox.Text).

    You should probably familiarize yourself with how to use expressions. Everything you are trying to do is very clearly documented in the manual.

    Thanks again So now, finally, my next step would be to save my Dictionary as JSON, and then link JSON with firebase? Is that right? I think understand more now, but yeah, you're definitely right. I need to go back and check out the manual, now.

  • Sry one more thing... I noticed that I can't click on the very 1st key saved in the list (unless I write in a second key/message. Only then, can I click on and read the 1st or original message).

  • I changed the condition to "on selection changed".

    If there is only one item in the list, it can't "change".

  • Thanks I understand. I changed it back to "on clicked" though.

    ... So now do I just need to save my Dictionary into a JSON file, and then link JSON file with firebase? Is that right? Lastly, is it possible to get the newest message/key to stay at the top, rather than move to the bottom... Can I change that?

  • Yes. You can save the dictionary as json to firebase, where any client can access the whole thing. You'll need to rebuild the list of keys after downloading to access it though.

    Yes to your second question as well. You can find out how on the manual page. https://www.scirra.com/manual/155/list

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)