-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Entry cursor is not visible with animations off #4508
Comments
You could disable animations using the build tag no_animations https://docs.fyne.io/explore/compiling |
This operation is similar to my commented code. It does not require any changes to the underlying fyne library. It solves the problem of high CPU usage, but there is no input cursor for this operation. I see that the above code actually has cursor.Show(). Show() in the code above, but for some reason it doesn't show it. |
With animation disabled. The cursor doesn't have a color. I don't know if this is the original design intent. The following code change adds a new line and I added a comment. This solves the problem of the cursor not showing up when there is no animation. I'm not very familiar with fyne's own code. Please help me to see the right place to add this line and the right parameters. func (r *entryContentRenderer) Refresh() {
r.content.entry.propertyLock.RLock()
provider := r.content.entry.textProvider()
placeholder := r.content.entry.placeholderProvider()
focusedAppearance := r.content.entry.focused && !r.content.entry.disabled
selections := r.selection
r.updateScrollDirections()
r.content.entry.propertyLock.RUnlock()
if provider.len() == 0 {
placeholder.Show()
} else if placeholder.Visible() {
placeholder.Hide()
}
if focusedAppearance {
r.cursor.Show()
if fyne.CurrentApp().Settings().ShowAnimations() {
r.content.entry.cursorAnim.start()
} else {
r.cursor.FillColor = theme.PrimaryColor() // set a color on no_animations mode
}
} else {
r.content.entry.cursorAnim.stop()
r.cursor.Hide()
}
r.moveCursor()
for _, selection := range selections {
selection.(*canvas.Rectangle).Hidden = !r.content.entry.focused
selection.(*canvas.Rectangle).FillColor = theme.SelectionColor()
}
canvas.Refresh(r.content)
} |
Thanks for this, that is indeed a bug. Your proposed solution looks great, you can probably edit the file in GitHub to propose the change. Thanks for the help. |
This is a duplicate of #1946 which still needs to be addressed in some way. (EG making the animation faster so there is a short rest period between blink-in and blink-out, or on desktop disabling the cursor animation entirely as it's not standard on desktops - at least GTK and Cocoa) |
It is still tracking a separate bug whereby with animations off the cursor will not be visible - so let's not close as duplicate. |
Changing title to reflect the bug this will be tracking |
It's still pretty impactful though. In Supersonic, if it's sitting idle but with the search bar focused, it uses 2x-3x the CPU load than if it's playing music but without any Entry widget focused |
Checklist
Describe the bug
When the Entry box receives focus, CPU usage will increase slightly. When there are many controls on a poorly configured machine, the window CPU usage can be high, even reaching up to 50%. This can make it difficult or impossible to input text properly.
How to reproduce
in the centos8 or other linux.
The code you provided compiles and runs on Linux.
When there are no operations performed, the CPU usage can be observed to range from approximately 1% to 3% using top comma.
When the mouse clicks on an Entry control widget, the CPU usage will increase to around 7-8%.
After clicking a button (focus is move out form Entry), the CPU usage will decrease to approximately 3% left or right.
I tried disabling the animation of the Entry widget, but despite the above operations, there was no significant increase in CPU usage. However, the cursor did not show up.
Screenshots
The focus is not on the Entry.
The focus on the Entry.
The focus move out Entry.
Example code
Fyne version
2.4.3, 2.4.2, 2.4.1, 2.3.5
Go compiler version
1.18.10
Operating system and version
centos8 or other linux
Additional Information
No response
The text was updated successfully, but these errors were encountered: