Skip to content

Commit

Permalink
Merge pull request #7 from moritz-t-w/fix-placeholder-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
moritztim authored Feb 13, 2024
2 parents 2c7bfcf + f136502 commit 8a57a16
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions addons/form/nodes/FormLabel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ 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:
push_error("Input ", input.get_instance_id(), " has no placeholder_text or text property")
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, ""]:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8a57a16

Please # to comment.