Scarse documentation for MenuBarSelected() Desktop Event


Once I am there, how do I know what MenuItem was selected ?

The debugger does not help either…

What I want to do ?

Trap the activated MenuBar… as the Event name imply…

If I follow myDMB, I suppose that I can detect the Main Menu Bar for the current window and that is not what I was searching.

The documentation says:

The user has selected a menu while the listbox has the focus.

You don’t. This event is really named badly now… as what it’s really telling you is that the user just clicked on something and that the menubar is about to be drawn. What you need to do in this event is you set up everything that needs custom code. So everything that needs to be enabled, disabled or changed based on the current state of your program, which isn’t covered by the auto-enable functionality.

A good example is File > Save. Typically this menu is only enabled after a document has already been saved once. So let’s say you have a class that represents your document, which has a folderitem property representing where its data is saved on disk. In this method, you could write something like this:

FileSave.Enabled = (myDoc.DiskFile <> Nil)

1 Like

in fact it is the old EnableMenuItems event in api1

1 Like

Thank you guys.