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

Fix SpinBox will reset unsubmitted text when redrawing #81638

Merged

Conversation

jsjtxietian
Copy link
Contributor

@jsjtxietian jsjtxietian commented Sep 14, 2023

This should fix #79507

As I mentioned in the issue, this commit added _update_text() to NOTIFICATION_DRAW. And insided _update_text(), it uses the shared range value to update the line_edit's text, but the value will override the unsubmited user's input.

Originally this commit makes sense because user may call set_value_no_signal which will directly change shared range's value, but when a user input some text and then triggered NOTIFICATION_DRAW, this could be wrong and cause this bug.

So we will encounter a situation where we have two sources of value that need to consider in _update_text, one from script like set_value_no_signal which directly change range's value , one from user's uncommited input reflected in line_edit compoment.

Basically what my fix do is that it trys to remember the last_updated_text, and when the value get from shared range equals this last_updated_text but not euqal to line_edit's current value, just return to keep line_edit's current value. That being saied, when a user is inputing something and some script called set_value_no_signal at the same time, this code will keep the shared range's value instead of user's input.

It should work in most cases, I know this is not the best fix, but I think it is less invasive in this way. I would appreciate any feedback or alternative suggestions.

@jsjtxietian jsjtxietian requested a review from a team as a code owner September 14, 2023 09:30
@Chaosus Chaosus added this to the 4.2 milestone Sep 14, 2023
@KoBeWi
Copy link
Member

KoBeWi commented Sep 23, 2023

When you press Escape to unfocus the SpinBox, anything you wrote will remain.

@jsjtxietian
Copy link
Contributor Author

When you press Escape to unfocus the SpinBox, anything you wrote will remain.

I guess this is not the expected behaviour? If the user do not turn on autosave, I guess it should drop the content after unfocus?

@KoBeWi
Copy link
Member

KoBeWi commented Sep 25, 2023

Yes, it's a bug. You can write some invalid non-numeric value and it will linger.

@jsjtxietian jsjtxietian changed the title Fix spinBox will reset unsubmited text when redrawing [WIP]Fix spinBox will reset unsubmited text when redrawing Sep 29, 2023
@jsjtxietian jsjtxietian force-pushed the fix-spinBox-reset-text-when-redraw branch from d7bf7e5 to 61be3ea Compare October 8, 2023 12:03
@jsjtxietian jsjtxietian changed the title [WIP]Fix spinBox will reset unsubmited text when redrawing Fix spinBox will reset unsubmited text when redrawing Oct 8, 2023
@akien-mga akien-mga changed the title Fix spinBox will reset unsubmited text when redrawing Fix SpinBox will reset unsubmited text when redrawing Oct 18, 2023
@akien-mga akien-mga merged commit 680b599 into godotengine:master Oct 18, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@jsjtxietian jsjtxietian deleted the fix-spinBox-reset-text-when-redraw branch October 18, 2023 15:07
@akien-mga akien-mga changed the title Fix SpinBox will reset unsubmited text when redrawing Fix SpinBox will reset unsubmitted text when redrawing Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SpinBox resets text when tooltip is showed
4 participants