Segmented Control Question?

  • Is it possible to set a segmented control's selection to none?  I have
    a three views of the same data that I would like to switch between
    using a segmented control.  I also have a few views of different data
    that are selected with separate toolbar buttons.  When I select one of
    these toolbar buttons, I need to tell the segmented control to set
    it's selection to none.  Any ideas or is this the completely wrong way
    to handle this situation?

    Thanks,
    Doug
  • On Feb 15, 2008, at 1:47 PM, Doug Penny wrote:

    > Is it possible to set a segmented control's selection to none?  I have
    > a three views of the same data that I would like to switch between
    > using a segmented control.  I also have a few views of different data
    > that are selected with separate toolbar buttons.  When I select one of
    > these toolbar buttons, I need to tell the segmented control to set
    > it's selection to none.  Any ideas or is this the completely wrong way
    > to handle this situation?

    I haven't actually tried this, but from the docs it *appears* that you
    could use -setSelected:forSegment: to deselect all segments.

    The "Segmented Controls Programming Guide" seems to support this, as
    it says "You can find out which segment, *if*any*, is selected...
    (emphasis mine).
  • Great!!  That works perfectly.  I don't know why I didn't notice that.
    For anyone else wondering, below is the code snippet I used to
    unselect the currently selected segment.

    [segmentedControl setSelected:NO forSegment:[segmentedControl selectedSegment]];

    Thanks,
    Doug

    On Feb 15, 2008 3:56 PM, Randall Meadows <cocoa-dev...> wrote:
    >
    > On Feb 15, 2008, at 1:47 PM, Doug Penny wrote:
    >
    >> Is it possible to set a segmented control's selection to none?  I have
    >> a three views of the same data that I would like to switch between
    >> using a segmented control.  I also have a few views of different data
    >> that are selected with separate toolbar buttons.  When I select one of
    >> these toolbar buttons, I need to tell the segmented control to set
    >> it's selection to none.  Any ideas or is this the completely wrong way
    >> to handle this situation?
    >
    > I haven't actually tried this, but from the docs it *appears* that you
    > could use -setSelected:forSegment: to deselect all segments.
    >
    > The "Segmented Controls Programming Guide" seems to support this, as
    > it says "You can find out which segment, *if*any*, is selected...
    > (emphasis mine).
    >