I can see several issues with your code. The first one is that the action 'fullscreen:' does probably not exist. If you look at the documentation of NSWindow you will see there is one called 'toggleFullScreen:' but if you try to use it you will also need to enable fullscreen for the NSWindow (because SDL does not do it) as otherwise the menu item will still be disabled. Here is a code example to do that, but it probably does not work in this case:
Code: Select all
NSWindow* window = [NSApp mainWindow];
NSWindowCollectionBehavior behavior = [window collectionBehavior];
behavior = behavior | NSWindowCollectionBehaviorFullScreenPrimary;
[window setCollectionBehavior:behavior];
nsString = constructNSStringFromCString(_("Fullscreen"), stringEncoding);
menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:@selector(toggleFullScreen:) keyEquivalent:@""];
[windowMenu addItem:menuItem];
[nsString release];
There are two reasons why I don't think it will work:
1- Setting the NSWindowCollectionBehaviorFullScreenPrimary when creating the menu is probably too early. We would need to do it a bit later.
2- Using the NSWindow toggleFullScreen is unlikely to be what you want.
What you probably need is to use the SDL fullscreen toggle, which is abstracted in the SCummVM class OSystem. To do that you will need to declare a new action that toggles the fullscreen using the OSystem API. Below is a code example where I do that by declaring a new class that inherit from NSMenuItem and contains the action we need. Hopefully that code should work.
First toward the top of the file (for example just after the NSApplication(MissingFunction) hack) declare the new class:
Code: Select all
@interface FullscreenMenuItem : NSMenuItem {
}
- (IBAction) ToggleFullScreenMode;
@end
@implementation FullscreenMenuItem
- (IBAction) ToggleFullScreenMode {
g_system->beginGFXTransaction();
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !g_system->getFeatureState(OSystem::kFeatureFullscreenMode));
g_system->endGFXTransaction();
}
@end
And now you can create the menu item this way:
Code: Select all
nsString = constructNSStringFromCString(_("Fullscreen"), stringEncoding);
menuItem = [[FullscreenMenuItem alloc] initWithTitle:nsString action:@selector(ToggleFullScreenMode) keyEquivalent:@""];
[menuItem setTarget:menuItem];
[windowMenu addItem:menuItem];
[nsString release];
Note that I create the menu item as a FullscreenMenuItem (the class I defined) and not as a NSMenuItem, and that I set itself as a target so that when triggered it look for the action in the FullscreenMenuItem.
If something is not clear in my explanations, don't hesitate to ask.
And out of curiosity, why are you trying to add this menu item?