Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 Cursor Animation on widget.Entry #1779
Fix Cursor Animation on widget.Entry #1779
Changes from 18 commits
3c03bc8
3b315f1
359f4dd
dc4f394
4f8559e
338d76d
9896435
f021577
db19a08
7403c99
365b868
4c56395
3fd96e1
8095c78
df544fa
cab80a9
5743eb4
5da8029
ff0ba74
3c5722d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the counter and the loop and I wondered if an alternative approach might be easier to read (and less background processing)... this is just thinking out loud.
Could you wait until you suspect the cursor would wake up (i.e. simple delay), then at that event see if the time has lapsed, and if not (because a new delay was added) then wait the difference between the first delay and the latter, eventually seeing there is no additional delay and return to the running animation?
This would also mean that the animation wakes up after the specified time, without needing to check every 10ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was the first thing I had in mind, but the problem is the reset part, if we do not check every "x" time then we will introduce some delays in the animation, or maybe I am wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I don't follow but my understanding was that it would always pause at least the delay time, which may get longer if the user keeps typing. So what is the reset event that we need to check sooner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok, I will implement the logic with a ticker instead maybe it is more clear with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have thought it would be. Worth exploring.
If it is cleaner without let me know and I will do a more thorough review of this code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andydotxyz Ok, I have updated the code using now time.Ticker. I am just worry if calling ticker.Reset() so quickly would lead to a bad performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, now I realized that time.Ticker does have Reset() method just from Go 1.15 😞, should I revert the last changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andydotxyz I have rewritten the solution with time.Timer instead of time.Ticker to ensure backwards compatibility with Go. Tests are ok now! :)