Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6320583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:59:57+00:00 2026-05-24T15:59:57+00:00

I am developing a Cocoa application and encountered a problem with highlighting. Standard highlighting

  • 0

I am developing a Cocoa application and encountered a problem with highlighting. Standard highlighting color in MAC OS X applications is blue, but it doesn’t suit my app, since because of design concepts, I need a green color for highlighting.

I tried to subclass NSTableview and override method

- (void)highlightSelectionInClipRect:(NSRect)clipRect

but it didn’t help.

How to fix this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:59:57+00:00Added an answer on May 24, 2026 at 3:59 pm

    I am using this, and so far works perfectly:

    - (void)highlightSelectionInClipRect:(NSRect)theClipRect
    {
    
            // this method is asking us to draw the hightlights for 
            // all of the selected rows that are visible inside theClipRect
    
            // 1. get the range of row indexes that are currently visible
            // 2. get a list of selected rows
            // 3. iterate over the visible rows and if their index is selected
            // 4. draw our custom highlight in the rect of that row.
    
        NSRange         aVisibleRowIndexes = [self rowsInRect:theClipRect];
        NSIndexSet *    aSelectedRowIndexes = [self selectedRowIndexes];
        int             aRow = aVisibleRowIndexes.location;
        int             anEndRow = aRow + aVisibleRowIndexes.length;
        NSGradient *    gradient;
        NSColor *       pathColor;
    
            // if the view is focused, use highlight color, otherwise use the out-of-focus highlight color
        if (self == [[self window] firstResponder] && [[self window] isMainWindow] && [[self window] isKeyWindow])
        {
            gradient = [[[NSGradient alloc] initWithColorsAndLocations:
                         [NSColor colorWithDeviceRed:(float)62/255 green:(float)133/255 blue:(float)197/255 alpha:1.0], 0.0, 
                         [NSColor colorWithDeviceRed:(float)48/255 green:(float)95/255 blue:(float)152/255 alpha:1.0], 1.0, nil] retain]; //160 80
    
            pathColor = [[NSColor colorWithDeviceRed:(float)48/255 green:(float)95/255 blue:(float)152/255 alpha:1.0] retain];
        }
        else
        {
            gradient = [[[NSGradient alloc] initWithColorsAndLocations:
                         [NSColor colorWithDeviceRed:(float)190/255 green:(float)190/255 blue:(float)190/255 alpha:1.0], 0.0, 
                         [NSColor colorWithDeviceRed:(float)150/255 green:(float)150/255 blue:(float)150/255 alpha:1.0], 1.0, nil] retain];
    
            pathColor = [[NSColor colorWithDeviceRed:(float)150/255 green:(float)150/255 blue:(float)150/255 alpha:1.0] retain];
        }
    
            // draw highlight for the visible, selected rows
        for (aRow; aRow < anEndRow; aRow++)
        {
            if([aSelectedRowIndexes containsIndex:aRow])
            {
                NSRect aRowRect = NSInsetRect([self rectOfRow:aRow], 1, 4); //first is horizontal, second is vertical
                NSBezierPath * path = [NSBezierPath bezierPathWithRoundedRect:aRowRect xRadius:4.0 yRadius:4.0]; //6.0
                    [path setLineWidth: 2];
                    [pathColor set];
                    [path stroke];
    
                [gradient drawInBezierPath:path angle:90];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
I am relatively new to developing Cocoa applications on the Mac and come from
I am developing a cocoa application that will be making heavy use of both
I am developing a Cocoa application which communicates constantly with a web service to
I'm a newbie Cocoa developer and I'm developing my first application. I want to
I am developing an application for the Mac as a small team (me +
I'm developing a Cocoa application, and I'm using constant NSString s as ways to
I am developing a Cocoa application which involves a chat element. One approach I've
I'm developing a Cocoa application and want to be able to click a button
I am pretty new in developing cocoa applications. I have developed a small UI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.