Re: Removing the Filename flag in Doc. based Application
Re: Removing the Filename flag in Doc. based Application
- Subject: Re: Removing the Filename flag in Doc. based Application
- From: Mark Piccirelli <email@hidden>
- Date: Tue, 27 May 2008 14:33:45 -0700
There's some advice about this in the "Advice for Overriders of -
[NSDocument displayName]" section of the AppKit release notes at http://developer.apple.com/releasenotes/Cocoa/AppKit.html.
(Searching for "advice" on that page turns up a couple of other
tidbits too.)
-- Mark
On May 24, 2008, at 1:02 AM, Caleb Strockbine wrote:
On May 23, 2008, at 2:51 PM, email@hidden wrote:
How do I set my document based application to omit the filename
reference at
the top of each opened document window?
Kyle Sluder's explanation is quite informative, but it may also be
more complicated than you need. If you really just want to change
the name of your document, you can override -[NSDocument
displayName] like this:
// Adding this method to your document subclass will cause the
// title of every document window to be "Foo".
- (NSString *)displayName
{
return @"Foo";
}
If you want to also remove the file proxy icon (small icon next to
the window title), you'll likely want to create a custom window
controller as described by Kyle and implement either the -
windowDidLoad: or -awakeFromNib methods such that you get a
reference to the icon button and send it a -setHidden: message, like
this:
// Put the following in your custom window controller where it'll
// be executed soon after the window is loaded.
NSButton *fileButton =
[window standardWindowButton:NSWindowDocumentIconButton];
if (fileButton != nil) {
[fileButton setHidden:YES];
}
The reason for putting the code above in a custom window controller
is that ideally, your document class shouldn't be in the business of
defining what the window should look like. The window controller is
a better place for that.
cheers,
Caleb Strockbine
_______________________________________________
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
_______________________________________________
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