Yes, theonelabel is the name of the Label. And actually your code indeed works. I'm sure the problem lies somewhere within my scenario.
My function is built right into a Button I use for erasing what other Buttons write into a Label (I created a number-pad...):
func _my_erase_button():
var linetext = get_node(the_one_label).text
linetext.erase(linetext.length()-1,1)
get_node(the_one_label).text = linetext
if linetext.empty():
print ("No Text in Label")
if not linetext.empty():
print ("There's actually something written in the Label!")
And like this everything works - tapping (number-)buttons to add numbers and tapping the erase-button to erase one position. What I try to do is to make this erase-button disabled when the Label is empty so there's actually nothing to erase. And this works fine by simply adding disabled = true
under if linetext.empty():
.
What does not work, however, is getting the button back to work again as soon as something is written into the label by adding disabled = false
under if not linetext.empty():
. The button stays disabled... printing works, but not this.
What could the little detail be I'm missing here?