Re: Small variant of NSSearchField?
Re: Small variant of NSSearchField?
- Subject: Re: Small variant of NSSearchField?
- From: John Stiles <email@hidden>
- Date: Mon, 10 Mar 2008 15:59:55 -0700
OK, I figured it out. My control's frame was too tall!
If you set the search field's frame to be more than 19 pixels tall, it
creates a large-sized variant even if you explicitly asked for the small
version. I was using 21 pixels, which is smaller than the regular size
of 22 pixels—so it was cropping pixels—but not small enough, apparently.
This is entirely different from the rest of the controls in Cocoa, which
honor the requested NSControlSize no matter what frame you use. You can
make a mini NSButton with a 50-pixel tall frame, and it draws just fine.
(The button just centers itself within its frame.)
I'll file a radar on this since it's clearly inconsistent, but at least
there is a workaround! Thanks for the help, guys :)
Tom Bunch wrote:
It does seem to be order dependent. This works (though it does drop
the baseline a pixel)
[[searchField cell] setControlSize:NSSmallControlSize];
[searchField setFont:[NSFont systemFontOfSize:[NSFont
systemFontSizeForControlSize:NSSmallControlSize]]];
NSRect searchFrame = [searchField frame];
NSSize cellSize = [[searchField cell] cellSizeForBounds:searchFrame];
searchFrame.size.height = cellSize.height;
[searchField setFrame:searchFrame];
If you don't set the font first, cellSizeForBounds: doesn't give
you the size you want.
-Tom
On Mar 10, 2008, at 3:45 PM, John Stiles wrote:
I've done all of these things, and so far no dice.
The small control clearly has a different overall look—for instance,
the magnifying glass icon has a smaller variant which I do not see.
Also, when I set the smaller frame, it's just using the big-size
control and cutting off its bottom edge, which looks dumb.
I also tried calling -sizeToFit but this had no effect.
Any other ideas?
Jonathan Hess wrote:
Hey John -
IB also typically changes the cell's font, and the control's frame
when you use the pop up in the control size inspector.
Hope that helps -
Jon Hess
On Mar 10, 2008, at 3:27 PM, John Stiles wrote:
Interface Builder can easily make a small variant of
NSSearchField—it's right there in the size popup—but I can't manage
to reproduce the effect in code. The typical approach doesn't work:
[[searchField cell] setControlSize:NSSmallControlSize];
does nothing at all, though this does shrink almost any other
control type I can think of.
I searched the archives and found that another user had this
problem in mid-2007, but there was no solution posted.
Any ideas?
_______________________________________________
Cocoa-dev mailing list (email@hidden
<mailto: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 <mailto:email@hidden>
_______________________________________________
Cocoa-dev mailing list (email@hidden
<mailto: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 <mailto: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