Re: Mixed-state checkboxes
Re: Mixed-state checkboxes
- Subject: Re: Mixed-state checkboxes
- From: Ken Thomases <email@hidden>
- Date: Fri, 08 Jul 2016 20:40:20 -0500
On Jul 8, 2016, at 7:36 AM, Jonathan Taylor <email@hidden> wrote:
>
> I'm trying to work out the correct way to handle a mixed-state checkbox (NSButton checkbox with allowsMixedState=YES), bound to a property on my controller. I am intending it to serve as an "applies to all" type control at the head of a column of checkboxes - so if other checkboxes in the column are toggled, it will display a state of on (if all in column are on), off (if all are off), or mixed if there is a mixture of states in the column.
> It seems that allowsMixedState makes it possible to *present* the mixed state, but also means that the user can click through the three states in order. What I believe the normal interface would be in my situation is for a user click on a box in on (or off) state to switch it to off (or on), and a click on mixed state puts it to either on or off (not sure which). What I would not expect is for a click when in off state to put it into MIXED state. In this interface (if I have described it clearly!) it makes no sense for the user to actively put the checkbox into mixed state.
You could try using a custom subclass of NSButtonCell that overrides -nextState. Your override would examine the current state and return either NSOnState or NSOffState (never NSMixedState), depending on what the current state is. So: NSOnState -> NSOffState, NSOffState -> NSOnState, NSMixedState -> one of NSOnState or NSOffState as you prefer (or as super behaves), and, for good measure, handle the case where the current state isn't any of the above, too.
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