Skip to content

Parameter input: change text modification logic#142

Merged
dbnicholson merged 1 commit intomainfrom
improve-lineedit-input
Jul 18, 2024
Merged

Parameter input: change text modification logic#142
dbnicholson merged 1 commit intomainfrom
improve-lineedit-input

Conversation

@manuq
Copy link
Copy Markdown
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



func _on_line_edit_text_changed(new_text):
func _on_line_edit_text_submitted(new_text):
Copy link
Copy Markdown
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
Copy Markdown
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
@manuq manuq force-pushed the improve-lineedit-input branch from 4500268 to 9f3f1a7 Compare July 17, 2024 23:44
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

manuq commented Jul 18, 2024

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

Copy link
Copy Markdown
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
@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