Programatically creating a checkbox

  • How does one do it? The NSButton docs list many different types of
    bezel, but none seem to correspond to a checkbox type. I can easily
    create one in IB, but that doesn't give me enough info to recreate it
    programatically. (I even tried examining it with F-Script Anywhere,
    but that didn't reveal anything obvious either.)

    I know that one viable solution would be to create a checkbox in a
    nib and then just copy it as necessary, but that seems like overkill
    just to make one dinky little checkbox :)
  • On Nov 18, 2007, at 7:34 PM, John Stiles wrote:

    > How does one do it? The NSButton docs list many different types of
    > bezel, but none seem to correspond to a checkbox type. I can easily
    > create one in IB, but that doesn't give me enough info to recreate
    > it programatically. (I even tried examining it with F-Script
    > Anywhere, but that didn't reveal anything obvious either.)

    I think you want -[NSButton setButtonType:NSSwitchButton].

    --
    adam
  • On Nov 18, 2007, at 7:34 PM, John Stiles wrote:

    > How does one do it? The NSButton docs list many different types of
    > bezel, but none seem to correspond to a checkbox type
    >
    ... apart from the one described in "Using Switch Buttons"...

    mmalc
  • OK, should I file a documentation bug then?
    Checkboxes have never been called switches on this operating system.

    On Nov 18, 2007, at 8:07 PM, mmalc crawford wrote:

    >
    > On Nov 18, 2007, at 7:34 PM, John Stiles wrote:
    >
    >> How does one do it? The NSButton docs list many different types of
    >> bezel, but none seem to correspond to a checkbox type
    >>
    > ... apart from the one described in "Using Switch Buttons"...
    >
    > mmalc
    >
  • On Nov 18, 2007, at 8:35 PM, John Stiles wrote:

    > OK, should I file a documentation bug then?
    > Checkboxes have never been called switches on this operating system.

    Use the feedback form at the bottom of the documents page... I agree
    that the naming isn't the first thing that comes to mind, I think
    checkbox.

    -Shawn
  • Hey John -

    To configure an NSButton as a checkbox, set the buttonType with -
    [NSButtonCell setButtonType:] to NSSwitchButton, then set the
    bezelStyle to to NSRegularSquareBezelStyle with -[NSButtonCell
    setBezelStyle:]. You'll probably also want to set the imagePosition to
    NSImageLeft.

    Good Luck -
    Jon Hess

    On Nov 18, 2007, at 7:34 PM, John Stiles wrote:

    > How does one do it? The NSButton docs list many different types of
    > bezel, but none seem to correspond to a checkbox type. I can easily
    > create one in IB, but that doesn't give me enough info to recreate
    > it programatically. (I even tried examining it with F-Script
    > Anywhere, but that didn't reveal anything obvious either.)
    >
    > I know that one viable solution would be to create a checkbox in a
    > nib and then just copy it as necessary, but that seems like overkill
    > just to make one dinky little checkbox :)
  • On Nov 18, 2007, at 11:35 PM, John Stiles wrote:

    > OK, should I file a documentation bug then?
    > Checkboxes have never been called switches on this operating system.
    >

      Huh? The button type has *always* been "NSSwitchButton".

    --
    I.S.
  • On 19 Nov 2007, at 12:07, I. Savant wrote:

    > On Nov 18, 2007, at 11:35 PM, John Stiles wrote:
    >
    >> OK, should I file a documentation bug then?
    >> Checkboxes have never been called switches on this operating system.
    >>
    >
    > Huh? The button type has *always* been "NSSwitchButton".

    I think he means that it should be called NSCheckboxButton, the
    assumption being that they were called "switches" on NeXT/OpenSTEP and
    that NSSwitchButton is a hangover from that.

    Kind regards,

    Alastair.

    --
    http://alastairs-place.net
  • Or at least, documenting that "NSSwitchButton" makes a "checkbox."
    The documentation is highly unclear:

    NSToggleButton
    After the first click, the button displays its alternate image or
    title; a second click returns the button to its normal state.

    This option is called “Toggle” in Interface Builder’s Button Inspector.

    NSSwitchButton
    This style is a variant of NSToggleButton that has no border.

    This type of button is available as a separate palette item in
    Interface Builder.

    (http://developer.apple.com/documentation/Cocoa/Reference/
    ApplicationKit/Classes/NSButtonCell_Class/Reference/Reference.html#//
    apple_ref/doc/c_ref/NSSwitchButton)
    The word checkbox, in fact, is not listed once on the entire page :(

    On Nov 19, 2007, at 4:40 AM, Alastair Houghton wrote:

    > On 19 Nov 2007, at 12:07, I. Savant wrote:
    >
    >> On Nov 18, 2007, at 11:35 PM, John Stiles wrote:
    >>
    >>> OK, should I file a documentation bug then?
    >>> Checkboxes have never been called switches on this operating system.
    >>>
    >>
    >> Huh? The button type has *always* been "NSSwitchButton".
    >
    > I think he means that it should be called NSCheckboxButton, the
    > assumption being that they were called "switches" on NeXT/OpenSTEP
    > and that NSSwitchButton is a hangover from that.
    >
    > Kind regards,
    >
    > Alastair.
    >
    > --
    > http://alastairs-place.net
    >
    >
  • On Nov 19, 2007, at 8:01 AM, John Stiles wrote:

    > (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSButtonCell_Class/Reference/Reference.html#/

    > /apple_ref/doc/c_ref/NSSwitchButton)
    > The word checkbox, in fact, is not listed once on the entire page :(
    >
    The answer to your question can still be found trivially using <http://developer.apple.com/cgi-bin/search.pl?&q=Programmatically+creati
    ng+checkbox&num=10&site=default_collection
    >...

    mmalc
  • You don't think it's even the slightest bit odd that the NSButtonCell
    docs don't contain the word "checkbox" anywhere on the page? Seems like
    a no-brainer omission to me. Not all of us came from OpenStep land.
    So I filed a radar anyway:

    5608038    Docs: NSButtonCell reference page does not mention
    "checkbox" anywhere

    Hopefully someone out there thinks this is worth addressing in a doc update.

    mmalc crawford wrote:
    >
    > On Nov 19, 2007, at 8:01 AM, John Stiles wrote:
    >
    >> (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSButtonCell_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSSw
    itchButton
    )
    >>
    >> The word checkbox, in fact, is not listed once on the entire page :(
    >>
    > The answer to your question can still be found trivially using
    > <http://developer.apple.com/cgi-bin/search.pl?&q=Programmatically+creati
    ng+checkbox&num=10&site=default_collection
    >...
    >
    >
    > mmalc
    >
  • On Nov 19, 2007, at 9:42 AM, John Stiles wrote:

    > You don't think it's even the slightest bit odd that the
    > NSButtonCell docs don't contain the word "checkbox" anywhere on the
    > page? Seems like a no-brainer omission to me.
    >
    Yes, I do think it's an omission, and it will be addressed in the next
    release (the programming guide was updated last night).

    That said, to reiterate, finding an answer to the original question
    was trivial...

    mmalc
  • On Monday, November 19, 2007, at 12:45PM, "John Stiles" <JStiles...> wrote:
    > You don't think it's even the slightest bit odd that the NSButtonCell
    > docs don't contain the word "checkbox" anywhere on the page? Seems like
    > a no-brainer omission to me. Not all of us came from OpenStep land.

    I did come from OpenStep land, and I still find it weird (perhaps because I came from the Mac before NextStep).

    > So I filed a radar anyway:
    >
    > 5608038    Docs: NSButtonCell reference page does not mention
    > "checkbox" anywhere

    I just sent in feedback using the link at the bottom of the NSButtonCell page.  Thanks for prompting me to do so.

    --Andy
  • On Nov 19, 2007, at 11:29 AM, Andy Lee wrote:

    > On Monday, November 19, 2007, at 12:45PM, "John Stiles" <JStiles...>
    >> wrote:
    >> You don't think it's even the slightest bit odd that the NSButtonCell
    >> docs don't contain the word "checkbox" anywhere on the page? Seems
    >> like
    >> a no-brainer omission to me. Not all of us came from OpenStep land.
    > I did come from OpenStep land, and I still find it weird (perhaps
    > because I came from the Mac before NextStep).
    >
    Likewise.  Although curiously I don't immediately see any other
    feedback or enhancement requests about this, and the document's about
    a decade old.  That said...

    >> So I filed a radar anyway:
    >> 5608038    Docs: NSButtonCell reference page does not mention
    >> "checkbox" anywhere
    > I just sent in feedback using the link at the bottom of the
    > NSButtonCell page.  Thanks for prompting me to do so.
    >
    ... thanks, but to anyone else, please don't submit any more requests,
    it's already fixed (and will appear in the next documentation update).

    mmalc
  • On Nov 19, 2007, at 4:23 PM, mmalc crawford wrote:

    > On Nov 19, 2007, at 11:29 AM, Andy Lee wrote:
    >
    >> On Monday, November 19, 2007, at 12:45PM, "John Stiles"
    >> <JStiles...> wrote:
    >>> You don't think it's even the slightest bit odd that the
    >>> NSButtonCell
    >>> docs don't contain the word "checkbox" anywhere on the page?
    >>> Seems like
    >>> a no-brainer omission to me. Not all of us came from OpenStep land.
    >> I did come from OpenStep land, and I still find it weird (perhaps
    >> because I came from the Mac before NextStep).
    >>
    > Likewise.  Although curiously I don't immediately see any other
    > feedback or enhancement requests about this, and the document's
    > about a decade old.  That said...

    Well, I can recall hunting around for it awhile back but I just
    figured I was dumb so I didn't create any feedback.

    I did stumble across this under "Using Switch Buttons" in "Button
    Programming Topics for Cocoa" and just figured "hmm, that's a funny
    name for a checkbox!"

    > A switch button displays the setting of something in your
    > application. Another name for a switch button is checkbox.
    >

    I too come from Mac Toolbox land :)
previous month november 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    
Go to today