• 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: Programatically adding small checkboxes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programatically adding small checkboxes


  • Subject: Re: Programatically adding small checkboxes
  • From: Ken Tozier <email@hidden>
  • Date: Mon, 2 May 2005 23:16:26 -0400

Thanks Todd. I tried it out but am still getting the normal size checkboxes. Do you see the error in this snippet?

NSRect        frameRect            = [self bounds],
              checkboxRect;

                

    checkboxRect    = NSMakeRect(frameRect.origin.x + 8, frameRect.origin.y + 8, 20, 20);

    NSButton        *checkButton    = [[NSButton alloc] initWithFrame: checkboxRect];
    NSButtonCell    *checkCell      = [[NSButtonCell alloc] init];

    [checkCell setButtonType: NSSwitchButton];
    [checkCell setState: NSOnState];
    [checkButton setCell: checkCell];
    [self addSubview: checkButton];


Ken

On May 2, 2005, at 10:42 PM, Todd Yandell wrote:

Hi,

You could do either of the two things you mentioned.

If you want to change the size of an NSButton control, try something along these lines:
[[yourButton cell] setControlSize:NSSmallControlSize];

If you want to add an NSCell subclass to an NSView, then you will need a "host" view. NSCell doesn't provide any of the NSView methods on it's own, instead it requires another view (like NSButton, for instance) to provide all of the NSView-compatible methods for it. This helps keep NSCell instances more light-weight so they can be used over and over without all of the overhead of an NSView. So, you can either add it directly to an instance of NSControl/NSButton (setCell:), or add it to an NSMatrix or another similar class.

Hope that helps!
Todd Yandell

 _______________________________________________
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

  • Follow-Ups:
    • Re: Programatically adding small checkboxes
      • From: Andy Lee <email@hidden>
References: 
 >Programatically adding small checkboxes (From: Ken Tozier <email@hidden>)
 >Re: Programatically adding small checkboxes (From: Todd Yandell <email@hidden>)

  • Prev by Date: Re: Headless Cocoa/Java app - autorelease
  • Next by Date: Re: splitter subviews resize
  • Previous by thread: Re: Programatically adding small checkboxes
  • Next by thread: Re: Programatically adding small checkboxes
  • Index(es):
    • Date
    • Thread