0 votes

Hello,

I'm making a to-do-list system, and i want to be able to edit list items once they've been created. For that, i made a "Form" scene where i can write/select/check/choose stuff, and i want that form to appear when i chose to edit an item, and disappear and return the data that was entered by the user when i click a "confirm" button.
I'm not of what would be the best way to do that. Here is my current idea:

  1. The form scene can send a custom "confirmed" signal containing data grabbed from the form.
  2. When i click edit on a list item, a function create an instance of the form scene, and connect to it's "confirmed" signal.
  3. the user can do whatever they want with the form.
  4. when they click the "confirm" button, the "confirmed" signal is emitted, and the form disappear

When the list item receive the "confirmed" signal carrying the data, it adjust itself accordingly.

This seems to work okay, but i'm not satisfied by the fact that it requires connecting/deconnecting signals and differents function to open the form and get the data, which might get messy if i add new things to the system, or if i try to do something similar in an other context.

I want to know if this is a good/bad way of doing it, and if they are better ways to achieve my goal.

I'm imagining a function that open the form, let the user changes things, then grab the data and return it/edit the item when confirmed is clicked on the form.
But i have no idea how to achieve something similar, and i wonder if it's even possible/good practice to have a function "wait" for a button click like that.

I'm new to godot, so i'm open to any comment even vaguely related to my issue.

Thanks in advance

Godot version 3.3.2
in Engine by (16 points)

I'm pretty sure you have to do it like this. yield can wait for signals, but that's really the only way to make it more efficient.

It looks like it yes, thank you for your input.

1 Answer

0 votes

Apparently there isn't really a better solution when it comes to sending the data back.
I ended up passing a reference to the Item list object as an argument to the form when creating it, so it can be directly modified from there. It looks less messy than having multiple signal, not sure it's good practice though.

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.