0

In TextEdit, if you click the little dropdown next to the filename you get a menu which shows a couple of entries including Rename, Move to iCloud, Move To, Duplicate, Lock and finally Browse All Versions.

TextEdit

I'm wondering how to support this menu? On my app I have the disclosure indictor, but get no menu which I click it. Do I need to add this menu via code? If so, i'm assuming I need to link it to the window somehow, but I don't see a proper place to do so. Any suggestions on what i'm missing?

SQL

Kyle
  • 16,103
  • 26
  • 123
  • 231
  • Did you put the disclosure triangle there? I like your Toolbar Icons BTW! – trojanfoe Dec 11 '12 at 13:37
  • @trojanfoe I did not add the disclosure triangle. I was working on adding version support and the disclosure triangle appeared once I returned true for both `preservesVersions` and `autosavesInPlace` for my NSDocument object. Thanks for the comment on the icons, i'll pass it onto the designer! – Kyle Dec 11 '12 at 13:50

2 Answers2

3

You get this functionality "for free" when using NSDocument subclasses in document-based applications. As long as you've implemented everything outlined here:

http://developer.apple.com/library/mac/#documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html

... versioning should "automagically" work as it's directly affected by implementing auto-save.

Things to consider:

  1. What's the minimum OS version you're targeting?
  2. Are you customizing anything to do with the Window's title bar?
  3. Does your NSDocument subclass implement modern (non-deprecated) read/write methods or are you doing something "old or funky"?
Joshua Nozzi
  • 59,504
  • 12
  • 135
  • 133
  • 1. I'm ok supporting 10.7+ 2. I am not doing any customization to the title bar. 3. I believe the methods I'm subclassing as modern: `- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError` and `- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError`. I've gone through that document and I'm fairly certain that I have added support for everything. I think at this point, I'm going to attempt creating a basic text editing app and see if I can get versions working. – Kyle Dec 11 '12 at 15:21
  • Looking at your answer above, I'd say "messing with the title bar's menu" counts as "customizing anything to do with the window's title bar." :-) Glad you found it. Please mark your answer as accepted to close the question. – Joshua Nozzi Dec 11 '12 at 16:30
0

Figured it out. I was overriding:

- (void)menuNeedsUpdate:(NSMenu *)menu

I didn't need to be overriding this method, so I removed it. As soon as I did that, my menu started working.

Kyle
  • 16,103
  • 26
  • 123
  • 231