One Quickie

Unslecting all segments with radio-mode tracking (NSSegmentedControl->Hacks)
NSSegmentedControl won't let you unselect all segments if there is currently one segment selected (it's perfectly happy with having everything unselected so long as nothing else is selected). This is annoying, so you have to go into the Momentary tracking mode, unselect each of the cells, then go back to the original mode.

In my NSSegmentedControl category, I have a method to solve this problem:

@interface NSSegmentedControl (BorkwareAdditions)
- (void) unselectAllSegments;
// ... other goodies
@end // NSSegmentedControl

- (void) unselectAllSegments
    NSSegmentSwitchTracking current;
    current = [self trackingMode];

    [self setTrackingMode: NSSegmentSwitchTrackingMomentary];

    int i;
    for (i = 0; i < [self segmentCount]; i++) {
        [self setSelected: NO  forSegment: i];

    [self setTrackingMode: current];

} // unselectAllSegments

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book