// size the image for our menu
NSSize size;
size.width = [[NSFont menuFontOfSize:0] pointSize];
size.height = size.width;
This works like a charm.
On Apr 28, 2008, at 9:39 AM, Adam R. Maxwell wrote:
On Apr 28, 2008, at 7:18 AM, glenn andreas wrote:
On Apr 27, 2008, at 11:44 PM, Adam R. Maxwell wrote:
Sure, but you have no way of knowing what the correct size is for
an NSMenuItem (assuming you want a normal size). I set all menu
item images to 16x16 since that looks approximately correct, but
I'd rather have NSMenuItem draw the image at the correct size, or
have something like -[NSMenuItem height] to get a nominal, future-
proof size.
NSMenuItem doesn't actually have a "correct size" - it calculates
its size based on its contents. So a large font in an attributed
string title will cause it to have a larger size, as will setting
an image (or NSView for Leopard).
So asking the menu item for the size isn't the right way to do it -
it's going to say "as large as it needs to be to hold everything".
You don't care how big it is - you want the image to look good with
the menu text.
Instead, it since you want the image to match the size of the text,
so you'd probably be better off by getting the font and measuring
its line height.
Thanks; I never thought of taking that route! In case anyone else
has trouble finding the menu font and size, you can use [NSFont
menuFontOfSize:0] to get the correct font.
--
adam
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/kmmx%40mac.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]