Enable MenuItem

Hi Everyone,

I’m a bit confused about the following fact:
I have a MainMenubar with an Menuitem e.g. “Details” and named it to “mDetails”. I set AutoEnable to False.

If a row in a Listbox is selected, mDetail should set to Enabled = True, else False.
[h]My Code[/h]

Sub Change() If Me.ListIndex > -1 Then mDetails.Enabled = True Else mDetails.Enabled = False End If End Sub

I work with Xojo Version 2014.2 and compile a Cocoa Application!

How to get it working?

Best regards!

You will need to enable and disable your menu item in the enableMenuitems event of the screen

Hi Roger,
thats laborious, but it works fine. I created a BooleanVariable, called EnableDetails!

Sub Change() If Me.ListIndex > -1 Then EnableDetails = True Else EnableDetails = False End If End Sub

Thank You!

Really? Seems so simple to me. Glad you got it working.

Just put this code in the EnableMenuItems event of the window:

mDetails.Enabled = ( Listbox1.ListIndex > -1 )

Replace Listbox1 with the name you gave your listbox in the window editor.