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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:43:22+00:00 2026-06-12T17:43:22+00:00

I have a borderless NSButton that contains an image and is subclassed with my

  • 0

I have a borderless NSButton that contains an image and is subclassed with my ButtonEffect class to detect mouseEntered and mouseExited events. My goal is to have just the edge of the image glow as the mouse enters the button area. I know I can achieve this by using two different images (one with shadow and another without) but I need to do this with one image.

Here’s an example of what I hope to achieve for the mouseEntered event:
mouse entered button area

And here’s what it should look after the cursor leaves the button area:
mouse exited button area

Here’s my attempt by setting the background of the cell but it changes the color of the entire button area.

#import "ButtonEffect.h"

@interface ButtonEffect ()

@property NSTrackingArea *trackingArea;

@end

@implementation ButtonEffect

- (void)updateTrackingAreas {
    [super updateTrackingAreas];

    if (_trackingArea) {
        [self removeTrackingArea:_trackingArea];
    }

    NSTrackingAreaOptions options = NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow;
    _trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect options:options owner:self userInfo:nil];
    [self addTrackingArea:_trackingArea];
}

- (void)mouseEntered:(NSEvent *)event {
    [[NSCursor pointingHandCursor] set];
    [self.cell setBackgroundColor:NSColor.redColor];
    NSLog(@"mouse entered button");
}

- (void)mouseExited:(NSEvent *)event {
    [[NSCursor arrowCursor] set];
    [self.cell setBackgroundColor:nil];
    NSLog(@"mouse exited button");
}

@end
  • 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-06-12T17:43:24+00:00Added an answer on June 12, 2026 at 5:43 pm

    You want something like this?

         - (void)mouseEntered:(NSEvent *)event {
        CALayer *lay=[btn layer];
        CGColorRef myColor=CGColorCreateGenericRGB(1, 1, 1, 1);
        CGColorRelease(myColor);
        myColor=CGColorCreateGenericRGB(0, 0, 0.8, 1);
        [lay setBorderColor:myColor];
        [lay setBorderWidth:1];
        [btn setWantsLayer:YES];
        [btn setLayer:lay];
        CGColorRelease(myColor);
    
    }
    
    - (void)mouseExited:(NSEvent *)event {
        CALayer *lay=[btn layer];
        CGColorRef myColor=CGColorCreateGenericRGB(1, 1, 1, 1);
        CGColorRelease(myColor);
        myColor=CGColorCreateGenericRGB(0, 0, 0.8, 1);
        [lay setBorderColor:myColor];
        [lay setBorderWidth:0];
        [btn setWantsLayer:YES];
        [btn setLayer:lay];
        CGColorRelease(myColor);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a borderless window over NSTextField with a NSButton in that window. canBecomeKeyView returns
I have a borderless form that I'm docking onto the top edge of my
I have a borderless NSWindow subclass that I use as part of a document
I have a borderless WPF window (WindowStyle=None) that can be moved by catching LeftMouseDown
I have code that lets be drag around a borderless form in winforms that
I want to have Borderless window similar to image I have attached; how can
I have a subclassed NSView that I would like to contain an editable NSTextField,
I have created a borderless (and scrollbox-less) console application, but I have found that
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

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.