• 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: Fixing NSSegmentedControl Display Bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fixing NSSegmentedControl Display Bug


  • Subject: Re: Fixing NSSegmentedControl Display Bug
  • From: Benjamin Einstein <email@hidden>
  • Date: Thu, 28 Dec 2006 14:00:37 -0500

All has been fixed! It seems to always happen that just when you ask for help you figure it out.

I was making a bit of a mistake in the preference pane viewer with dynamic loading of the principal class of the bundle. Apparently, and I didn't know this, if the class you specify in the Plist file can't be found, XCode assigns any other class it can find as the principal class. All is well.

On Dec 28, 2006, at 12:09 PM, Benjamin Einstein wrote:

Hi All:

As you may know, there's a display bug with NSSegmentedControl when using NSTexturedBackgroundWindowMask window style and size Regular for the control. Like most mac developers, the 1 or 2 missing pixels from the top of the control really gets to me and I HAVE to fix this problem. Luckily, I found a post of someone using a brilliant little trick to override a private method that fixes the display bug:

#import <Cocoa/Cocoa.h>
#define NormalSegmentedCellStyle 1
#define FlatSegmentedCellStyle 2

@interface FixedSegmentedControl : NSSegmentedControl {

}
@end

@interface NSSegmentedCell ( PrivateMethod )
- (void)_setSegmentedCellStyle:(int)style;
@end

@implementation FixedSegmentedControl
- (void)awakeFromNib
{
    [self setFrameSize:NSMakeSize([self frame].size.width, 25)];
}

- (NSCell *)cell
{
    NSSegmentedCell *cell = [super cell];
    [cell _setSegmentedCellStyle:FlatSegmentedCellStyle];
    return cell;
}
@end

This works beautifully when run in any app I have that uses my custom window backing (which takes advantage of NSTexturedBackgroundWindowMask), however, I get the following when used in a preference pane:
[Session started at 2006-12-28 12:06:12 -0500.]
2006-12-28 12:06:15.708 MyApp[873] *** -[FixedSegmentedControl initWithBundle:]: selector not recognized [self = 0x3c5790]
2006-12-28 12:06:15.713 MyApp[873] Exception raised during posting of notification. Ignored. exception: *** -[FixedSegmentedControl initWithBundle:]: selector not recognized [self = 0x3c5790]


InitWithBundle gets called for the class of the prefpane not of the control within it (as far as I know). I've spend about 6 hours on this problem and can't figure it out!

I also get this very bizarre error when dragging my .h file into IB:
"Cannot define a category for unknown class NSSegmentedCell"
But the Custom class shows up and all appears normal.

Any help would be greatly appreciated!

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40comcast.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Fixing NSSegmentedControl Display Bug (From: Benjamin Einstein <email@hidden>)

  • Prev by Date: NSTreeControll and different entities
  • Next by Date: exclude from Window menu but show in Dock menu
  • Previous by thread: Fixing NSSegmentedControl Display Bug
  • Next by thread: NSTreeControll and different entities
  • Index(es):
    • Date
    • Thread