How to enable menu item whens popup selection changes

In a DesktopPopupMenu “SelectionChanged” event, I have the following line of code:

MainMenuBar.Child("FileMenu").Child("FileSave").Enabled = True

The File/Save menu item is disabled on application launch so changing the value on this popup should enable that menu whit this line of code. However, when I do this, it remains disabled. Am I missing something here?


When you created your menu you gave a name to this menu, in my exemple “FichSauvFichNbP”. In the event “MenuBarSelected” of “App”* you write “FichSauvFichNbP.Enabled = YourFlag”
So you set the value of YourFlag in your Popup change event, true or False depending of what you want to do (enable or Disable).

  • : You have to create this event in App (not in your Window because it does not work well).

When you created your menu you gave a name to this menu, in my exemple “FichSauvFichNbP”. In the event “MenuBarSelected” of “App”* you write “FichSauvFichNbP.Enabled = YourFlag”
So you set the value of YourFlag in your Popup change event, true or False depending of what you want to do (enable or Disable).

So the only place where MainMenuBar.Child("FileMenu").Child("FileSave").Enabled = True is valid is inside the event handlers for the menu? And that means the only way to do this is to set a flag for this menu’s state somewhere and then check it when the menu bar is clicked on?

I just set a break on MenuBarSelected, after having set the FileSave menu to enabled as above, but when I look at the File Save menu in the debugger, its Enabled state is shown as False.

Thanks

MenuBarSelected is the only place where you can enable/disable menu items. That’s the purpose of this event.

You have two ways:
• Have a flag that you set in your popup menu (e.g. property=FileSaveEnabled as boolean, code in MenuBarSelected=MainMenuBar.Child(“FileMenu”).Child(“FileSave”).Enabled=FileSaveEnabled).
• Directly query the state of the popup menu from MenuBarSelected: e.g. put this in MenuBarSelected: MainMenuBar.Child(“FileMenu”).Child(“FileSave”).Enabled=MyPopupMenu.SelectedRowIndex=3