• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set a mixed checkbox?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set a mixed checkbox?


  • Subject: Re: How to set a mixed checkbox?
  • From: John Pannell <email@hidden>
  • Date: Sat, 10 Jun 2006 21:40:13 -0600

Hi Marc-

I tried this out, and it mostly works the way I want. I have a hierarchy of checkboxes, so if one "upstream" is deselected, I want all the checkboxes downstream deselected; if (at least) one (but not all) of the downstream checkboxes are checked, then all the upstream checkboxes need to be set to a mixed state. This is all working. What is also happening is that when the user clicks on a checkboxes, Cocoa cycles through the on/off/mixed state. I don't want that--the user should only be able to turn on/off, with the app the only one setting the mixed state.

I recently implemented a similar view for my application (inspired by the behavior of the Apple Installer view, when you choose to customize an installation). The outline view column with the checkbox does need setAllowsMixedState:YES. In the action for the button, I simply checked to see if the sender was mixed, and clicked it again (in code) if so, like this:


	// user clicks cannot have mixed state
    if([[sender selectedCell] state] == NSMixedState){
        [[sender selectedCell] performClick:sender];
        return;
    }

This will cause the method to get called again, but now in the desired state (on or off).

Now, based on the state of the sender, and any siblings to the sender, you can set the state of any parent node buttons appropriately.

HTH!

John


John Pannell Positive Spin Media http://www.positivespinmedia.com


_______________________________________________ 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
References: 
 >How to set a mixed checkbox? (From: "email@hidden" <email@hidden>)
 >Re: How to set a mixed checkbox? (From: Greg Titus <email@hidden>)
 >Re: How to set a mixed checkbox? (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Embedding a database
  • Next by Date: Re: Embedding a database
  • Previous by thread: Re: How to set a mixed checkbox?
  • Next by thread: NSTextView and horizontal scroller?
  • Index(es):
    • Date
    • Thread