Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter input: change text modification logic #142

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

manuq
Copy link
Contributor

@manuq manuq commented Jul 17, 2024

Previously any text change was sending the modified signal, adding too many actions to the undo/redo history (one per typed character). This was also capturing shortcuts like Ctrl-Z for undoing and sending the modified signal, thus piling to the history, not going back.

Instead, send the modified signal when the line edit is submitted (enter key pressed) or when it loses focus and the text has changed.

https://phabricator.endlessm.com/T35566

@@ -126,10 +131,16 @@ func get_string() -> String:
return "%s" % input


func _on_line_edit_text_changed(new_text):
func _on_line_edit_text_submitted(new_text):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is also used to handle the Vector2 input signals. You'll need to split those to a separate function (arguably they should have been already).

Copy link
Contributor Author

@manuq manuq Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I totally missed that, good catch! PR updated. It is a bit boilerplate now. An alternative would be to connect to the callbacks in code (not in the Signals dock in the editor) and bind the corresponding LineEdit as argument. And also have a dict for the last text submitted, with each LineEdit as key.

@manuq manuq force-pushed the improve-lineedit-input branch 2 times, most recently from fa535ce to 4500268 Compare July 17, 2024 23:39
Previously any text change was sending the modified signal, adding too
many actions to the undo/redo history (one per typed character).
This was also capturing shortcuts like Ctrl-Z for undoing and sending
the modified signal, thus piling to the history, not going back.

Instead, send the modified signal when the line edit is submitted (enter
key pressed) or when it loses focus and the text has changed.

Do this for the 3 line edit nodes.

https://phabricator.endlessm.com/T35566
Copy link
Contributor

@dylanmccall dylanmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working well for me now.

@manuq
Copy link
Contributor Author

manuq commented Jul 18, 2024

@dbnicholson do you think this is good for merging now?

Copy link
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to check back on this! Yes, it looks good now!

@dbnicholson dbnicholson merged commit 7d3cea1 into main Jul 18, 2024
2 checks passed
@dbnicholson dbnicholson deleted the improve-lineedit-input branch July 18, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants