objective c - How to disable items from NSMenu for certain views? -
objective c - How to disable items from NSMenu for certain views? -
i've app 3 views presented in same window.
when user enters view 1 want items of main menu enabled, when enters view 2 other items , when come in view 3 want items disabled.
how can this?
read docs informal protocol nsmenuvalidation
: says: this informal protocol allows application update enabled or disabled status of nsmenuitem
object. declares 1 method, validatemenuitem
: in target object of menuitem have implement:
- (bool)validatemenuitem:(nsmenuitem *)menuitem { // item? nslog( @"validate %@", [menuitem title] ); // useful testing // homecoming this: if( [ [menuitem title] isequaltostring:@"show something"] ){ homecoming ! [view3 userishere]; } homecoming yes; }
in documentation method find example.
objective-c xcode osx
Comments
Post a Comment