Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSRulerView overtop of NSTableView?

Very basic scenario:

I have a NSTableView in my nib with an outlet pointing to it. I have the following in my app delegate:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    NSScrollView    *scroller = [tableView enclosingScrollView];

    [scroller setHasVerticalRuler: YES];
    [scroller setRulersVisible: YES];
}

The ruler gets displayed overtop of my tables headers (any any content):

Tableview with ruler overtop

See how column 1 is only partially visible. If I try the same exact thing with a textview, then it works perfect, the cursor gets indented and the text is clearly visible:

Textview proper

Could anyone point out what I'm doing wrong?

Edit: I've discovered that this is an issue with Yosemite that did not exist on older OS X versions. I've submitted a bug reports, but I guess the question would now be, does anybody know of a workaround?

A sample project has been uploaded here.

like image 705
Kyle Avatar asked Nov 11 '22 01:11

Kyle


1 Answers

The problem is in the NSScrollView, and it's not your fault. Basically, the reason why column1 is partially visible is because the horizontal scroller has an offset.

Anyway, this worked for me:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    NSScrollView    *scroller = [tableView enclosingScrollView];

    [scroller setHasVerticalRuler: YES];
    [scroller setRulersVisible: YES];

    NSPoint pointToScrollTo = NSMakePoint ( -25 , 0 );
    [[scroller contentView] scrollToPoint: pointToScrollTo];
    [scroller reflectScrolledClipView: [scroller contentView]];
}

Hope this helps.

like image 100
user2695712 Avatar answered Jan 04 '23 01:01

user2695712