-
Is there a way to run some function when a widget becomes visible? This is called "component life cycle" in Web UI's term. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There is not really an API for that at the moment. A hack (not technically meant to be used in that way and not guaranteed to happen exactly at that time) the CreateRenderer method of the widget will be called more or less when it gets visible. You can extend the widget and replace the CreateRenderer() method with your own (similar to https://developer.fyne.io/extend/extending-widgets). Just make sure that you return the result of the parent's CreateRenderer() method, otherwise it will not behave as expected (or not work at all). |
Beta Was this translation helpful? Give feedback.
There is not really an API for that at the moment. A hack (not technically meant to be used in that way and not guaranteed to happen exactly at that time) the CreateRenderer method of the widget will be called more or less when it gets visible.
You can extend the widget and replace the CreateRenderer() method with your own (similar to https://developer.fyne.io/extend/extending-widgets). Just make sure that you return the result of the parent's CreateRenderer() method, otherwise it will not behave as expected (or not work at all).