Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Payotz | |
Old Version | Published before Godot 3 was released. |
So basically, I’ve been getting my input from a LineEdit, setting it to a Label and adding the Label to a Panel. It’s working for the first run, like so:
The problem is, if I change the value, it doesn’t really “redraw” itself, rather it “draws over itself”, like so:
I have the Labels inside a Dictionary, so I can track it, and I have an if-check to prevent me from creating new Labels, so I think it’s not an issue of me creating new Labels each time.
I’ve also tried Panel.update(), but it doesn’t do anything.
I’ve also tried removing the Label at the start, and adding it again after I set the text, but again it doesn’t do anything.
Any ideas?
Are you sure there is only one label per line? (check the remote inspector)
More code showing your data structures and ways you set the text could be useful.
Scene structure too.
eons | 2017-03-23 17:54
So I checked the remote inspector and it really did have more than one label per line.
It turns out that there are more Labels per line, so I did a check that will make sure that a Label is a single line only, it worked:
Now I think the problem is not the Label drawing over itself, but it’s drawing two labels at the same line. Hence here:
Which doesn’t really make sense, since I often remove the label before adding it again. Unless, Panel.remove_child() doesn’t remove the child, or I haven’t been tracking the original Label at all.
This is my code:
button_list is where I track the buttons (water,gold,lumber,food) in the original question.
label_proposal_player is what I use to track the labels in question
button_quantity_list is where I track my line edits.
player_pressed is just to make sure that a single button click doesn’t make 8 Labels.
My scene tree is here:
The Panels are populated by the _ready function, and the _fixed_process(delta) function.
The _fixed_process() function calls on check_player_proposal_buttons() (because of the Label check thing)
add_item and want_item contains my lineEdit and buttons in the original question.
_ready():
Payotz | 2017-03-23 21:47
I think you could simplify a lot that process dividing the problem into scenes and using signals to change values, also using labels for visual representation only (but, as I use to say, depends on the design).
Back to the issue, it is possible that you lost the reference to the labels in some way, try storing the label path after adding them to the tree instead of the node itself (I know it fails in some arrays, maybe dictionary too).
To see where you lost the variables you can try to print the paths and the instance ID on the output when changing values and removing labels, before doing anything else.
eons | 2017-03-23 23:17