Following Peters advice:
Consider using a single-segment NSSegmentedControl. It has this
behavior built-in.
I am not completely satisfied: I want the NSOnState shown as done in
an NSButton with buttonType = NSOnOffButton and bezelStyle =
NSTexturedSquareBezelStyle.
In the header file I found a method:
[ segmentedControl setSegmentStyle: NSSegmentStyleSmallSquare ];
which has not yet found its way into the documentation, and which
comes closer to what I want:
Specifially: the NSOnState should look indented with a black
background.
And there should be almost no space wasted left and right of the
image or titel.
The wasted space was avoided with:
[ segmentedControl setLabel: name forSegment: 0 ];
[ segmentedControl sizeToFit ];
NSRect frame = [segmentedControl frame];
float nw = frame.size.width * 5.0 / 6.0 - 15.0 ; // very ugly hack,
but I don't know anything better
nw = ceil(nw);
[ segmentedControl setWidth: nw forSegment: 0 ];
[ segmentedControl sizeToFit ];
Also: a segmented control with an image has a lower height than one
with text. Which also reports a height of 24, but looks definitely
higher.
This crazyness stopped, once I stopped using:
//[ segmentedControl setFont: [ NSFont labelFontOfSize: 0.0 ] ];
Kind regards,
Gerriet.
_______________________________________________
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 arch...@mail-archive.com