Get data from form on confirmation/make a function "wait" for an other function

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaxElder


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

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.

Cogan | 2021-08-14 13:23

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

MaxElder | 2021-08-17 14:23

:bust_in_silhouette: Reply From: MaxElder

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.