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 3441150
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:31:04+00:00 2026-05-18T08:31:04+00:00

Is there a way to highlight a NSImageView with the default highlight color of

  • 0

Is there a way to “highlight” a NSImageView with the default highlight color of the mac? I’m simply looking for a way to tint my nsimageview so that the user can identify the object easily.

Thanks,

Kevin

  • 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-18T08:31:04+00:00Added an answer on May 18, 2026 at 8:31 am

    If one of the built-in options of NSImageView isn’t sufficient, you could subclass NSImageView, and in drawRect, do:

    - (void)drawRect:(NSRect)frame {
       [super drawRect:frame]; // this takes care of image
       [NSBezierPath setDefaultLineWidth:4.0];
       [[NSColor highlightColor] set];
       [NSBezierPath strokeRect:frame]; // will give a 2 pixel wide border
    }
    

    Ahh, to have it as a variable state, I’d probably define an instance variable then, such as isHighlighted to keep track of that state. Then, whenever anything happens that would change the highlighted state, you’ll set the view as needing redisplay. You could do this in the set/get methods for instance:

    - (void)setHighlighted:(BOOL)aHighlighted {
       isHighlighted = aHighlighted;
       [self setNeedsDisplay:YES];
    }
    

    Then, update your drawRect: method to take into account the isHighlighted flag. How you achieve an unhighlighted look may depend on the style of image view. You could try just calling super to do the drawing, but if in testing, you see any residual or stray highlighted pixel information that super’s drawing didn’t overwrite, you may want to first draw clear color, then call super.

    So, something like this:

    - (void)drawRect:(NSRect)frame {
       isHighlighted ? [[NSColor highlightColor] set] : [[NSColor clearColor] set];
       [NSBezierPath setDefaultLineWidth:4.0];
       if (isHighlighted) {
          [super drawRect:frame];
          [NSBezierPath strokeRect:frame]; // will give a 2 pixel wide border
       } else {
          [NSBezierPath fillRect:frame];
          [super drawRect:frame];
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can get Eclipse to highlight the use of the
Is there any way i can make my listactivity (rather listview) highlight the List
I know that I can highlight text and its automatically copied, but is there
Is there a way to highlight a word in a TextView, so you can
Is there a way to get ERC to highlight all lines that come in
Is there a way to change the highlight color when something is found with
Is there an easy way or an html editor that can find all like-phases
I’m using the jQuery UI Autocomplete plug-in . Is there a way to highlight
Is there a way to programmatically highlight an imageview in android? I am showing
Is there a way to do a selection highlight over all elements in a

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.