Re: NSWindow title bar icon without representedURL
Re: NSWindow title bar icon without representedURL
- Subject: Re: NSWindow title bar icon without representedURL
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 21 Feb 2008 13:35:01 +0100
Le 21 févr. 08 à 13:21, Jean-Daniel Dupas a écrit :
Le 21 févr. 08 à 13:07, email@hidden a écrit :
Hello All
I would like to place an icon in the window title bar without a
corresponding representedURL.
I know what the HIG says about this but I would like to emulate
finder's behaviour when selecting an item from its outline view
sidebar.
I have a list of local and network resources and would like the
titlebar icon to reflect the selection (local or network) as the
user may collapse the resource browser, denying them info regarding
the resource they are operating on.
Can I create an NSUrl proxy of some sort?
Or is just one of those "it's right in front of you, Dummy"
situations.
If so, please address replies to "Dear Dummy,".
The target is Leopard.
Regards
Jonathan
You was very close to the answer.
See what the -representedURL documentation says:
You can customize the file icon in the tile bar with the following
code:
[[<window> standardWindowButton:NSWindowDocumentIconButton]
setImage:<image>];
I do not send this message to "Dear dummy" because i didn't try and
don't know if it works ;-) Maybe it's not so
simple._______________________________________________
So, after a simple test, it appears that is not so simple.
[<window> standardWindowButton:NSWindowDocumentIconButton] returns
nil if there is no URL setted.
I find a workaround anyway:
[uiWindow setRepresentedURL:[NSURL fileURLWithPath:@"Your Window
Title"]];
NSImage *img = [NSImage imageNamed:@"EnergySaver"];
[img setSize:NSMakeSize(16, 16)]; // scale your image if needed (and
maybe should use userSpaceScaleFactor)
[[uiWindow standardWindowButton:NSWindowDocumentIconButton]
setImage:img];
And also implements this delegate function.
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu
*)menu {
return NO;
}
_______________________________________________
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