diff --git a/addons/form/nodes/FormLabel.gd b/addons/form/nodes/FormLabel.gd index d0845ac..39915ce 100644 --- a/addons/form/nodes/FormLabel.gd +++ b/addons/form/nodes/FormLabel.gd @@ -67,9 +67,11 @@ enum Mode { for prop in ["placeholder_text", "text"]: if has_property(input, prop): if mode == Mode.IN_INPUT: + if input[prop] != text: + input_text_backup = input[prop] input[prop] = text - else: - input[prop] = "" + elif input[prop] == text: + input[prop] = input_text_backup found = true break if !found&&mode == Mode.IN_INPUT: @@ -77,6 +79,8 @@ enum Mode { mode = Mode.SEPARATE visible = true +var input_text_backup := "" + ## Sets the label text to the input's name if it is empty and runs necessary setters func _enter_tree(): if input != null&&text in [null, ""]: @@ -158,8 +162,10 @@ func indicate_validity( print(msg) return valid -## Return validity of "Subject has property_name and it is not a method" +## Return validity of "Subject exist, has property_name and property_name is not a method" func has_property(subject: Object, property_name: StringName) -> bool: + if subject == null: + return false return property_name in subject&&!subject.has_method(property_name) ## Indicate validity on GUI input if event is relevant and validate_on_input