Borderless NSPopupButton with small arrows (like in Xcode header)
Borderless NSPopupButton with small arrows (like in Xcode header)
- Subject: Borderless NSPopupButton with small arrows (like in Xcode header)
- From: Keith Blount <email@hidden>
- Date: Fri, 17 Sep 2004 12:12:48 -0700 (PDT)
Hello,
I am trying to create a custom header view similar to
the one at the top of the editor in Xcode or BBEdit.
In both of these programs, they have header views that
look similar to table header views but above
NSTextViews, and there are NSPopupButtons inside these
header views from which you can select the file to
display in the text view.
The header view itself is straightforward - I've just
created a custom view in a strip, and drawn an image
on it to make it look like a header view. But getting
the popup button to look right is a lot more difficult
than I thought it would be. Setting a basic,
borderless popup button of mini control size is easy
enough, of course; I just do it like this:
aPopup = [[NSPopUpButton alloc]
initWithFrame:NSMakeRect(0.0, 00.0, 75.0, 14.0)
pullsDown:NO];
[[aPopup cell] setControlSize:NSMiniControlSize];
[aPopup setFont:[NSFont systemFontOfSize:[NSFont
smallSystemFontSize]]];
[aPopup setBordered:NO];
[[aPopup cell]
setBezelStyle:NSShadowlessSquareBezelStyle];
[[aPopup cell] setArrowPosition:NSPopUpArrowAtBottom];
[aPopup addItemWithTitle:@"An item"];
[aPopup addItemWithTitle:@"Another item"];
[aPopup sizeToFit];
[[[self window] contentView] addSubview:aPopup];
I thought that this would have the desired effect, but
it doesn't. Even though it's set to NSMiniControlSize,
with no border the arrows are still rather large -
much bigger than the ones in the popup buttons in
Xcode or BBEdit. This is an issue not only because I
would like to conform to the look of other programs
with similar features, but also because my custom
header view is ony 16 pixels high, but sizing a mini
borderless popup button to fit makes it bigger than
that (and I need to size to fit in order for the
selected item's text to fit properly).
I have found that the settings I need to use above are
weird anyway. For instance, I don't understand why I
have to set a bezel style when I am using no border -
but I do. If I don't, the arrows fly off the top of
the button.
Does anybody know how I can create an NSPopupButton
that looks just like the ones at the top of the editor
in Xcode? I'm probably missing something obvious, but
if somebody could point me in the right direction, I
would be very grateful.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
_______________________________________________
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