Mulit-state buttons

  • Hi guys. I need a button that can be toggled between an arbitrary set
    of states. I my app I have a NSPopup button with 6 items for x,y,z,-
    x,-y and -z. I want to replace it a button that will cycle through
    all six states (showing alternative text/icon) for each one, looping
    around at the first. Perhaps I'm missing something but none of the
    standard widgets seem capable of this, and a google search has turned
    up nothing. I used to be able to do this in PowerPlant.

    Does anyone know of any available controls/classes to accomplish
    this? I can probably write a NSView subclass to do it but it would
    lack the polish of a true NSButton class (behavior, focus ring,
    selection, bindings etc). I want it to look and behave like a normal
    aqua toggle button.

    Help appreciated.
  • > Hi guys. I need a button that can be toggled between an arbitrary set
    > of states. I my app I have a NSPopup button with 6 items for x,y,z,-
    > x,-y and -z. I want to replace it a button that will cycle through
    > all six states (showing alternative text/icon) for each one, looping
    > around at the first. Perhaps I'm missing something but none of the
    > standard widgets seem capable of this, and a google search has turned
    > up nothing. I used to be able to do this in PowerPlant.

      A view?! That's what cells are for! Have you seen this:

    http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Tasks
    /SubclassingNSCell.html


      You can create your own NSButtonCell class that keeps track of these
    states ...

    --
    I.S.
  • Am 18.10.2007 um 21:26 Uhr schrieb Ari Benzane:

    > I my app I have a NSPopup button with 6 items for x,y,z,-x,-y and -
    > z. I want to replace it a button that will cycle through all six
    > states (showing alternative text/icon) for each one, looping around
    > at the first.

    Are you sure that's a good idea? It will then take five mouse clicks
    to get from y to x, instead of just two with the pop up.
    Also you can't really see which choice is up next so it might happen
    easily that you 'overshoot' and have to click even more often.

    Just saying ...

    Andreas
  • "I. Savant" <idiotsavant2005...> wrote:
      A view?! That's what cells are for! Have you seen this:

    http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Tasks
    /SubclassingNSCell.html


      You can create your own NSButtonCell class that keeps track of these
    states ...

    OK I'll have a look at this. I was hoping that someone had already implemented such a class. I assume a button cell could also be used in a table?

    @Andreas - you have a agood point. The ideal widget would also have a drop-down menu with items for each state. This would give the best of both worlds. Not sure how I could do that with an NSButtonCell however.


    ---------------------------------
    Nervous about who has your email address? Yahoo! Mail can help you win the war against spam.
  • > OK I'll have a look at this. I was hoping that someone had
    > already implemented such a class. I assume a button cell could also be used
    > in a table?

      You'd know the answer to that is yes if you'd go ahead and read the
    documentation I referenced.

    > @Andreas - you have a agood point. The ideal widget would also have a
    > drop-down menu with items for each state. This would give the best of both
    > worlds. Not sure how I could do that with an NSButtonCell however.

      Consider an NSSegmentedControl. All possible 'states' are visible in
    one control (showing they belong together) and a single click will get
    you the correct state.

    --
    I.S.
  • > You'd know the answer to that is yes if you'd go ahead and read the
    > documentation I referenced.

    Why did you even type that?

    >
    > Consider an NSSegmentedControl. All possible 'states' are visible in
    > one control (showing they belong together) and a single click will get
    > you the correct state.

    I'll try that but I'm limited on space and it doesn't sound very
    intuitive.
  • On 10/19/07, Ari Benzane <aribenzane...> wrote:
    >> You'd know the answer to that is yes if you'd go ahead and read the
    >> documentation I referenced.
    >
    > Why did you even type that?

      Two reasons:

      1 - Because you directly asked.
      2 - Because it's 100% true.
      3 - It's easier than copying and pasting what you should've read to
    begin with.

      Does it surprise you that someone who went to the trouble to point
    you toward the relevant reading material reminded you to actually read
    it when you've admitted to ignoring it as you ask yet another
    question? The statement was not made with malice and neither is this
    one: Read the documentation.

      The answer to all the basic cell-related questions you might have
    (and many you wouldn't think of) are in the guide I referenced. That
    guide is the basis for understanding all Cocoa controls (because
    controls use cells, etc.). My response was a direct answer to your
    questions and then some, but it's up to you to do your homework.

    --
    I.S.
  • > Two reasons:

      ... okay, there were three. ;-)

    --
    I.S.
  • On Oct 19, 2007, at 9:49 AM, Ari Benzane wrote:

    >> You'd know the answer to that is yes if you'd go ahead and read the
    >> documentation I referenced.
    >
    > Why did you even type that?
    >
    >>
    >> Consider an NSSegmentedControl. All possible 'states' are
    >> visible in
    >> one control (showing they belong together) and a single click will
    >> get
    >> you the correct state.
    >
    > I'll try that but I'm limited on space and it doesn't sound very
    > intuitive.

    NSPopupButton?
  • >
    > Two reasons:
    >
    > 1 - Because you directly asked.
    > 2 - Because it's 100% true.
    > 3 - It's easier than copying and pasting what you should've read to
    > begin with.
    >
    > Does it surprise you that someone who went to the trouble to point
    > you toward the relevant reading material reminded you to actually read
    > it when you've admitted to ignoring it as you ask yet another
    > question? The statement was not made with malice and neither is this
    > one: Read the documentation.
    >
    > The answer to all the basic cell-related questions you might have
    > (and many you wouldn't think of) are in the guide I referenced. That
    > guide is the basis for understanding all Cocoa controls (because
    > controls use cells, etc.). My response was a direct answer to your
    > questions and then some, but it's up to you to do your homework.

    Whoa. Excuse me Mr perfection.
  • Ari, he's completely right, and you need to listen to his advice.

    On Oct 19, 2007, at 10:42 AM, Ari Benzane wrote:

    >>
    >> Two reasons:
    >>
    >> 1 - Because you directly asked.
    >> 2 - Because it's 100% true.
    >> 3 - It's easier than copying and pasting what you should've read to
    >> begin with.
    >>
    >> Does it surprise you that someone who went to the trouble to point
    >> you toward the relevant reading material reminded you to actually
    >> read
    >> it when you've admitted to ignoring it as you ask yet another
    >> question? The statement was not made with malice and neither is this
    >> one: Read the documentation.
    >>
    >> The answer to all the basic cell-related questions you might have
    >> (and many you wouldn't think of) are in the guide I referenced. That
    >> guide is the basis for understanding all Cocoa controls (because
    >> controls use cells, etc.). My response was a direct answer to your
    >> questions and then some, but it's up to you to do your homework.
    >
    > Whoa. Excuse me Mr perfection.
  • On Oct 19, 2007, at 1:42 PM, Ari Benzane wrote:

    >> Whoa. Excuse me Mr perfection.

      (sigh) When you're done with the childish attitude, take a look at
    the guide I referred you to. It *will* help you accomplish your goal.

    --
    I.S.
  • On Oct 19, 2007, at 1:42 PM, Ari Benzane wrote:
    > Whoa. Excuse me Mr perfection.

    Nice attitude.  When people who are asking for help have this
    attitude, I really want to help them.

    --Andy
  • On Oct 19, 2007, at 10:45 PM, Andy Lee wrote:

    > On Oct 19, 2007, at 1:42 PM, Ari Benzane wrote:
    >> Whoa. Excuse me Mr perfection.
    >
    > Nice attitude.  When people who are asking for help have this
    > attitude, I really want to help them.

    Ari's response wasn't appropriate, but please don't pile on publicly.
    it doesn't help the signal to noise ratio.
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today