Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Versions in OSX 10.7

I have enabled versions and autosave in my document based app so now I can see the version browser (the time-machine-like interface) for each of my documents in OSX 10.7

+ (BOOL)autosavesInPlace{ return YES; }

I have a textview in it and as suggested in one of WWDC videos, session 107, I want to disable the text input, etc when entering into the version browser. So I implemented NSWindowDelegate methods:

- (void)windowWillEnterVersionBrowser:(NSNotification *)notification{
    [myTextView setEditable:NO];
}
- (void)windowWillExitVersionBrowser:(NSNotification *)notification{
    [myTextView setEditable:YES];
}

Now, myTextView in the document (the current document) window of the left side of the screen is disabled but the documents in the right side (the pasts versions) still show the cursor.

The textView is not editable but the cursor shows. I am also disabling other stuff and re-enabling them in above methods but writing code in above methods seems to affect only the current document window/document not the past versions windows/document.

Perhaps someone else is having the same problem? How can I get this work correctly? :)

EDIT:

I was looking for WWDC sample code of session 107, but the folder is empty. Did I miss something or there is no sample code for this session?

Edit2:

Application Kit Release Note (Lion) says that windowForSheet is called when creating the windows of the right side of version Browser:

- (NSWindow *)windowForSheet{
    CustomWindow *win = (CustomWindow *)[super windowForSheet];
    [win setUserInteractionEnabled:![self isInViewingMode]]; //disable stuff here
    return win;
}

But now when window goes back from the version Browser the user interaction is still disabled. :(

like image 462
nacho4d Avatar asked Jul 27 '11 06:07

nacho4d


1 Answers

Eventually I found the answer:

NSWindowDelegate methods are called for the current document's window (document in the left side of the version browser)and the other windows can be coordinated by overriding -[NSDocument windowForSheet]; or even better by writing something similar inside -[NSDocument windowControllerDidLoadNib:];.

I posted a-short-tutorial/notes here: Versions in OSX 10.7

like image 89
nacho4d Avatar answered Sep 27 '22 22:09

nacho4d