Finding a Fyne menu item to enable/disable it

  Kiến thức lập trình

I have a Fyne app with a MainMenu and need to enable/disable menu items in response to events. For example, the “Save” menu option should only be enabled when the user is working with a file.

My approach is to have a single EnableDisableMenuItems() function and call it whenever application state that should result in menu changes happens.

Is there a ‘right’ way to find the Save menu item in my EnableDisableMenuItems() function? Should I keep a reference to it somewhere and use that reference? Iterate through all items in the menu until I find a matching label? Something else?

LEAVE A COMMENT