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
Automatically remove focus from a widget that is no longer in the object tree #4812
Comments
This actually confused me recently because after switching content the canvas keyboard/shortcut events weren't working as expected, so I had to sprinkle Unfocus() calls all over the place; just to give an example what it does in terms of behaviour. While logical, it's not very obvious. Also not sure where I would look for it in the documentation though, or if it's even in there already. |
Related: #4374 |
Perhaps this should happen on container.Remove. It's less expensive than doing it on every refresh. It does mean you need to use container.Remove instead of directly setting container.Objects to get the benefits though |
Sounds like a good intermediate. Then the complete solution would be set up when we fix the gap that manually removing widgets does not |
Also semi-related: #4374 |
Another note - I would think that destroying renderers should be done on a periodic schedule, like a garbage collection/cache cleaning task. A widget that is removed from display ideally should immediately be unfocused, but that doesn't necessarily apply to render deletion - because the widget could be shown again shortly later. Supersonic is actually using a widget-cache system kind of similar to the collection widgets but for large-scale components of the "pages" or screens of the app, so that quick navigation doesn't create too many new widgets/CanvasObjects. |
Checklist
Is your feature request related to a problem?
If you have a widget that is focused, and you update the contents of the app window such that the widget is no longer visible, it will still be focused.
Is it possible to construct a solution with the existing API?
App code can manually unfocus things
Describe the solution you'd like to see.
On Refresh calls, Fyne can walk the object tree and unfocus the focused widget if it is no longer in the object tree. There are possible performance considerations here to think about - we don't want to be walking the tree more than necessary, and if it causes a large performance impact we should probably just not do it.
The text was updated successfully, but these errors were encountered: