I have a NSMenuItem
, and I create it using this:
NSMenuItem* nsMenuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:menuItem->getText()] action: keyEquivalent:@""];
Now I pass in a function pointer, which I want to call when the selector gets invoked.
How do I do this?
I have tried:
id block = [^{
functionPointer();
} copy];
NSMenuItem* nsMenuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:menuItem->getText()] action:@selector(invoke) keyEquivalent:@""];
[nsMenuItem setTarget:block];
However, the menu item is still grayed out.
How do I pass in a function pointer as a selector?
I'm building a cross platform app, and so basically I call to create a new menu, and my core C++ code will pass in a function pointer for the Menu Item.