* nested sheet. On the other hand I think there are good
* practical reasons for wanting it that way. Uncertain.
*
- * - User feedback suggests we should have `File' and `Edit' menus
- * like everyone else, so some menu reorg is probably required,
- * along with some documentation rewording.
- *
- * - User feedback also dislikes nothing happening when you start
- * the app; they suggest a finder-like window containing an icon
- * for each puzzle type, enabling you to start one easily. Needs
+ * - User feedback dislikes nothing happening when you start the
+ * app; they suggest a finder-like window containing an icon for
+ * each puzzle type, enabling you to start one easily. Needs
* thought.
*
* Grotty implementation details that could probably be improved:
[self processButton:'r'&0x1F x:-1 y:-1];
}
+- (void)copy:(id)sender
+{
+ char *text;
+
+ if ((text = midend_text_format(me)) != NULL) {
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSArray *a = [NSArray arrayWithObject:NSStringPboardType];
+ [pb declareTypes:a owner:nil];
+ [pb setString:[NSString stringWithCString:text]
+ forType:NSStringPboardType];
+ } else
+ NSBeep();
+}
+
+- (BOOL)validateMenuItem:(NSMenuItem *)item
+{
+ if ([item action] == @selector(copy:))
+ return (ourgame->can_format_as_text ? YES : NO);
+ else
+ return [super validateMenuItem:item];
+}
+
- (void)clearTypeMenu
{
while ([typemenu numberOfItems] > 1)
@interface AppController : NSObject
{
}
-- (void)newGame:(id)sender;
+- (void)newGameWindow:(id)sender;
@end
@implementation AppController
-- (void)newGame:(id)sender
+- (void)newGameWindow:(id)sender
{
const game *g = [sender getPayload];
id win;
id item =
initnewitem([DataMenuItem allocWithZone:[NSMenu menuZone]],
menu, gamelist[i]->name, "", self,
- @selector(newGame:));
+ @selector(newGameWindow:));
[item setPayload:(void *)gamelist[i]];
}
}
item = newitem(menu, "Quit", "q", NSApp, @selector(terminate:));
[NSApp setAppleMenu: menu];
- menu = newsubmenu([NSApp mainMenu], "Open");
+ menu = newsubmenu([NSApp mainMenu], "File");
+ item = newitem(menu, "New Game", "n", NULL, @selector(newGame:));
+ item = newitem(menu, "Restart Game", "r", NULL, @selector(restartGame:));
+ item = newitem(menu, "Specific Game", "", NULL, @selector(specificGame:));
+ [menu addItem:[NSMenuItem separatorItem]];
{
+ NSMenu *submenu = newsubmenu(menu, "New Window");
int i;
for (i = 0; i < gamecount; i++) {
id item =
initnewitem([DataMenuItem allocWithZone:[NSMenu menuZone]],
- menu, gamelist[i]->name, "", controller,
- @selector(newGame:));
+ submenu, gamelist[i]->name, "", controller,
+ @selector(newGameWindow:));
[item setPayload:(void *)gamelist[i]];
}
}
-
- menu = newsubmenu([NSApp mainMenu], "Game");
- item = newitem(menu, "New", "n", NULL, @selector(newGame:));
- item = newitem(menu, "Restart", "r", NULL, @selector(restartGame:));
- item = newitem(menu, "Specific", "", NULL, @selector(specificGame:));
[menu addItem:[NSMenuItem separatorItem]];
+ item = newitem(menu, "Close", "w", NULL, @selector(performClose:));
+
+ menu = newsubmenu([NSApp mainMenu], "Edit");
item = newitem(menu, "Undo", "z", NULL, @selector(undoMove:));
item = newitem(menu, "Redo", "S-z", NULL, @selector(redoMove:));
[menu addItem:[NSMenuItem separatorItem]];
- item = newitem(menu, "Close", "w", NULL, @selector(performClose:));
+ item = newitem(menu, "Copy", "c", NULL, @selector(copy:));
menu = newsubmenu([NSApp mainMenu], "Type");
typemenu = menu;