Re: NSRoundRectBezelStyle still doesn't work with NSPopUpButton?
Re: NSRoundRectBezelStyle still doesn't work with NSPopUpButton?
- Subject: Re: NSRoundRectBezelStyle still doesn't work with NSPopUpButton?
- From: Ryan Britton <email@hidden>
- Date: Wed, 21 Sep 2005 06:13:52 -0700
I accomplished this by using my own custom NSPopUpButtonCell
subclass. This may not be the best way, but it worked for my needs.
You just need to make sure of a few things at popup button creation:
[popupButton setFont:[NSFont systemFontOfSize:12.0]]; //This is the
closest to the font used by the spotlight search in finder I could
come up with
[popupButton setBezelStyle:NSRoundRectBezelStyle];
[[popupButton cell] setArrowPosition:NSPopUpNoArrow];
Here's my cell subclass:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSImage *arrows;
float x, y;
[super drawWithFrame:cellFrame inView:controlView];
arrows = [NSImage imageNamed:@"popupArrows"];
x = NSMaxX(cellFrame) - 10.0 - [arrows size].width;
y = (NSHeight(cellFrame) - [arrows size].height) / 2 + [arrows
size].height;
[arrows compositeToPoint:NSMakePoint(x, y)
operation:NSCompositeSourceOver];
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView
{
cellFrame.size.width -= 14.0;
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
On Sep 21, 2005, at 4:27 AM, Mason Mark wrote:
Does anybody know of a way to make NSPopUpButton work with the new
Spotlight-esque NSRoundRectBezelStyle? Googles finds this question
repeated here and there, but no answers.
(In case you wonder, the end goal here is to create a Spotlight
search-building UI just like the 10.4 Finder's.)
I coded the Spotlight support in the next version of our app before
10.4 shipped, so I kind of gambled with he assumption that this was
a pre-release bug that would be fixed for release. But it still
seems broken as of 10.4.2.
The symptom is that when the bezel style of an NSPopUpButton is set
to NSRoundRectBezelStyle the popup arrow is drawn in an incorrect
location, no matter what you set the arrow position to.
Since the GUI designer in Interface Builder has all sorts of bugs
with specifying sizes for controls, and also can't set some common
control properties, I laid out all the popups in the nibs involved
using IB's default widgets, and then our Spotlight framework
iterates over them after the nibs are loaded to adjust their
properties. (See the single-method category below.)
BUT, there still seems to be no way to make NSPopUpButton work with
the new Tiger bezel style?
If true, my next step would be to try to convince my boss to allow
me to just make all the popups standard Aqua popups. Then, I would
have to tediously go through all the nibs and adjust them, because
Aqua HIG specifies different sizes and metrics than what is
actually used in the new unnamed "Spotlight" interface.
So, if somebody knows some magic, I'd be glad. (For the record, I
lobbied against adopting this new "spotlight-freakout" UI, but our
decision was to mimic the Finder's UI for Spotlight searching...)
Thanks for any insights,
--
Mason Mark
Five Speed Software, Inc.
http://www.fivespeed.com/iget
-------
@implementation NSPopUpButton (FiveSpeedSpotlight)
- (void)fs_convertTo20PixelSpotlightThemedPopup;
{
[self setBezelStyle:NSRoundRectBezelStyle];
[[self cell] setArrowPosition:NSPopUpNoArrow];
NSRect f = [self frame];
f.size.height = 20.0;
[self setFrame:f];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden