Re: Modifying TextEdit.app
Re: Modifying TextEdit.app
- Subject: Re: Modifying TextEdit.app
- From: Andy Lee <email@hidden>
- Date: Thu, 21 Aug 2008 14:18:31 -0400
On Aug 21, 2008, at 1:55 PM, R.L. Grigg wrote:
Yes, that's a cool feature. But if I have three versions of
AppController.m up at once, it would be great to be reminded -- at a
glance -- which one is which, especially since I get so many
interruptions. So if the path was on the title bar, that'd be cool.
But I guess it's not so easy to change TextEdit to do this.
Did you not see my earlier reply?
On Aug 20, 2008, at 12:26 PM, Andy Lee wrote:
Sounds like TextEdit is an NSDocument-based app. I'm not familiar
with those, but I see NSDocument has a -displayName method whose
documentation says:
"If the document has been saved, the display name is the last
component of the directory location of the saved file (for example,
“MyDocument” if the path is “/tmp/MyDocument.rtf”). If the document
is new, NSDocument makes the display name “Untitled n,” where n is a
number in a sequence of new and unsaved documents. The displayable
name also takes into account whether the document’s filename
extension should be hidden. Subclasses ofNSWindowController can
override windowTitleForDocumentDisplayName:to modify the display
name as it appears in window titles."
This would explain why you didn't see an explicit call to -setTitle:
in the code -- that's taken care of by the framework. You can
override to customize the framework's default behavior.
I just added the following to DocumentWindowController and it had the
desired effect:
- (NSString *)windowTitleForDocumentDisplayName:(NSString *)displayName
{
NSURL *fileURL = [[self document] fileURL];
if (fileURL)
return [fileURL path];
else
return [super windowTitleForDocumentDisplayName:displayName];
}
I would have guessed there would be a simpler way, maybe a boolean you
could set. But this works.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden