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. :(
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With