Re: NSSegmentedControl's sizing behaviour
Re: NSSegmentedControl's sizing behaviour
- Subject: Re: NSSegmentedControl's sizing behaviour
- From: Graham Cox <email@hidden>
- Date: Wed, 11 Nov 2015 08:27:42 +1100
- X_v_e_cd: 8d0c8444d8ea0d1f5afb7fd057e87472
- X_v_r_cd: b0f6d07b28a19a80504db9fe4474bf0b
Thanks Ken, that works fine. Eyebrows a little bit raised that this is needed, but then segmented controls are horrible to deal with in any case.
—Graham
> On 10 Nov 2015, at 3:35 PM, Ken Thomases <email@hidden> wrote:
>
> On Nov 9, 2015, at 9:36 PM, Graham Cox <email@hidden> wrote:
>>
>> I’m struggling to get the behaviour I want from NSSegmentedControl.
>>
>> I want each segment to have the same width, which is the overall width of the control divided into equal parts. When the overall control is resized, the segment sizes should change, but remain equal to each other and fill the available width.
>>
>> Currently, I can either set the segments to have ‘automatic’ width, which sets them to be just enough to fit their icon, or ‘fixed’ width which is maintained, but in both cases the control size remains fixed and never visually resizes with the enclosing view. Unless the enclosing view is just right, the control is either too narrow, or too wide and clipped off. I have no idea in what universe this behaviour is supposed to be useful.
>>
>> Is there a way to set it up so it works how I want?
>
> I don't believe so, no. I'd suggest that you create a custom subclass of NSSegmentedControl. Override -setFrameSize: and have it set the sizes of the segments. I'd compare the current frame width to the sum of the segment widths. I expect there will be a constant extra amount for the border, etc. So, subtract that constant value from the new frame width, divide by 3, and use that for the new width of the segments.
>
> Regards,
> Ken
>
_______________________________________________
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