Search code examples
focusfyne

How do you set focus using fyne?


Using fyne, how can I set focus on a specific widget at app startup? Actually I cannot find a way to set focus anywhere. It seems you can only find when focus is gained or lost. I have spent more time trying to figure this out than I want to admit.


Solution

  • You can pass any widget that is focusable to Window.Canvas().Focus(...). If doing this at startup make sure that you have set the window content before calling this or the object lookup may fail (as the canvas must contain the widget before it can be focused).