cocoa - ValidateMenuItem is not getting called for NSMenuItem -


here sample class , usage:

@interface ccocoamenuitem : nsmenuitem  {    someclass *someobj; }   - (void)menueventhandler:(id)target; - (void)setenableitem:(bool)nenabled;  @end  @implementation ccocoamenuitem  - (bool)validatemenuitem:(nsmenuitem *)item {     // return yes or no based on conditions; // method not getting called   }  @end  ccocoamenuitem *dummyitem = [[ccocoamenuitem allocwithzone:[nsmenu menuzone]] initwithtitle:(nsstring*)astr action:nil keyequivalent:@""] autorelease]; [dummyitem setaction:@selector(menueventhandler:)]; [dummyitem settarget:dummyitem]; 

here validatemenuitem not getting called. have set action , target. target class object , have defined validatemenuitem in class only.

is there missing here?

in code you've posted, ccocoamenuitem declares menueventhandler: method in @interface, doesn't implement it. menu items aren't validated if target doesn't respond selector you've set action (such menu items disabled automatically).

btw, menuzone meant nsmenu, not nsmenuitem.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -