I’ve been struggling with NSTableView for the last two days. All I want to do 
is ensure the alternative “gray” highlight is used on a selection consistently 
instead of the heavy blue. Here’s my code:

-(void) killBlue
{
    NSInteger selectedRow = [_tableView selectedRow];

    if ([_tableView selectedRow] != -1)         //only call this if there is a 
selection
    {
        NSTableRowView *myRowView = [_tableView rowViewAtRow:selectedRow 
makeIfNecessary:NO];

       [myRowView 
setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleRegular];

        [myRowView setEmphasized:NO];

        [_tableView 
setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

    }

}

I’m calling this from three places:

1. In -tableViewSelectionDidChange: //to take care of user-initiated selection 
changes
2. In -tabViewToggle    //because the blue comes back when the TabView the 
TableView is embedded in is switched back and forth

and

3 and in -(void)applicationDidBecomeActive:(NSNotification *)aNotification 
//because the blue comes back when the app is switched in and out of frontmost

1 and 2 work fine. At first 3 only worked when the app was switched in an out 
of focus with the cmd-tab app switcher keys, but not when mouse clicks were 
used to change the frontmost app. To solve that problem, I also had to ensure 
something else was firstResponder when the app was made frontmost. 

I thought my troubles were over, until I discovered that despite those three 
implementations, I **still** get the blue highlighting in a situation where a 
row is highlighted (correctly appearing gray), then I click on any other app, 
then click back on the highlighted row (rather than somewhere else in the 
window) to make my app active again. Sure enough, there’s the blue. I’m 
exhausted trying to think of all the ways to defeat this blue highlighting and 
would appreciate some guidance. 

I’ve seen SE posts suggesting subclassing NSTableRowView, but I don’t 
understand why, since the property setEmphasized already exists in the parent 
class and should work across the board (shouldn’t it??).

Any thoughts much appreciated. 


Best

Phil


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to