I have a menu where some of the menu items use bindings to get their title. These items are always enabled, and don't neither automatically enable/disable like they should NOR do they cause a call to validateUserInterfaceItem:. If you remove the binding on title, then that starts working again. The menu items have the target set to nil (First Responder). If you click on one, it does execute the selector (action).
Bug? What to do?
For some reason when you set a menu item's title with bindings, the menu item becomes enabled
even if the target/action are nil
.
If you want to permanently disable the menu item you can workaround this by binding the menu item's enabled
status to a constant NO
:
NSNumber *alwaysNo = [NSNumber numberWithBool:NO];
[menuItem bind:@"enabled" toObject:alwaysNo withKeyPath:@"boolValue" options:nil];
Note that this isn't the most elegant workaround, but in my case it was still cleaner than not using bindings for the title.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With