Xojo Conferences
XDCMay2019MiamiUSA

[MBS] NSMenuItem.Enabled=False not working? (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Next thread: [MBS] ThreadSafeMBS / ThreadMBS


Re: [MBS] How to receive AppleScipt   -   Garth Hjelte
  [MBS] NSMenuItem.Enabled=False not working?   -   Marnaud
   Re: [MBS] NSMenuItem.Enabled=False not working?   -   Marnaud
   Re: [MBS] NSMenuItem.Enabled=False not working?   -   Christian Schmitz

[MBS] NSMenuItem.Enabled=False not working?
Date: 31.07.17 17:49 (Mon, 31 Jul 2017 18:49:09 +0200)
From: Marnaud
Hello,

I have this code in an open event of a PopupMenu control:

dim pb as NSPopUpButtonMBS=me.NSPopUpButtonMBS
dim menu as NSMenuMBS=pb.menu
dim MenuItem As NSMenuItemMBS

for i as integer=0 to menu.numberOfItems-1
MenuItem=menu.Item(i)
if MenuItem<>nil and MenuItem.Title="Test" then
MenuItem.Enabled=False
end if
next

Putting a breakpoint in the “MenuItem.Enabled=False” line, I’m seeing the statement is executed. However, the item is always enabled.

I can’t use the CarbonApplicationEvents class either (MenuPopulate event) because the obtained NSMenuMBS, given the passed handle, looks invalid (when using Menu.NumberOfItems, I get a CocoaException). As it’s for 64 bit, I can’t either use the MenuMBS way.

What is the workaround?
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSMenuItem.Enabled=False not working?
Date: 01.08.17 08:57 (Tue, 01 Aug 2017 09:57:37 +0200)
From: Marnaud
Le 31 juil. 2017 à 20:40 du soir, Christian Schmitz <<email address removed>> a écrit:

> Is NSMenuMBS configured to always enable maybe?

You’re right. I added “menu.autoenablesItems=False” and the item disables. Thank you.
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSMenuItem.Enabled=False not working?
Date: 31.07.17 19:40 (Mon, 31 Jul 2017 20:40:19 +0200)
From: Christian Schmitz

>
> I can’t use the CarbonApplicationEvents class either (MenuPopulate event) because the obtained NSMenuMBS, given the passed handle, looks invalid (when using Menu.NumberOfItems, I get a CocoaException). As it’s for 64 bit, I can’t either use the MenuMBS way.

Is NSMenuMBS configured to always enable maybe?

Sincerely
Christian