Search code examples
macoscocoasegmentedcontrol

How to change properties of 1 segment in a segmented cell?


How to change properties of 1 segment in a segmented cell? I can't find it. This is what i've tried:

  • Google
  • Some experimenting: _segmentedcell.SelectedSegment (does not work)

Here is my AppDelegate.h

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (weak) IBOutlet NSSegmentedCell *BackForward;
@property (weak) IBOutlet WebView *WebBrowser;
- (IBAction)BackForwardAction:(id)sender;

@property (assign) IBOutlet NSWindow *window;

@end

And here is my AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}

- (IBAction)BackForwardAction:(id)sender {
    if (_BackForward.selectedSegment == 0) {
        _WebBrowser.goBack;
        if (_WebBrowser.canGoBack == false) {
            //here it does need to disable segment 0
        }
    } else if (_BackForward.selectedSegment == 1) {
        _WebBrowser.goForward;
        if (_WebBrowser.canGoForward == false) {
            // here it does neet to disable segment 1
        }
    }
}
@end

Solution

  • I'm not sure how Google didn't lead you to the class reference for NSSegmentedControl, but:

    [_BackForward setEnabled:NO forSegment:0];