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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:36:47+00:00 2026-05-26T03:36:47+00:00

When creating Cocoa bevel button with custom image and alternate image I’m having a

  • 0

When creating Cocoa bevel button with custom image and alternate image I’m having a strange behavior. In the pressed state the button background becomes white.
I’m adding the button as subview of a transparent window (HUD window).

I’m trying every technique that I know:

NSButton *closeButton = [[NSButton alloc] initWithFrame:NSMakeRect(0.0, 0.0, 30.0, 30.0)];
        [closeButton setFrameOrigin:NSMakePoint(0.0, 0.0)];
        [closeButton setImagePosition:NSImageOnly];
        [closeButton setAction:@selector(closeWindowAction:)];
        [closeButton setBordered:NO];
        [closeButton setTransparent:NO];

        [closeButton setImage:[NSImage imageNamed:@"icon-tclose-off"]];
        [closeButton setAlternateImage:[NSImage imageNamed:@"icon-tclose-on"]];
        [closeButton setBezelStyle:NSShadowlessSquareBezelStyle];
        [closeButton setButtonType:NSMomentaryLightButton];

        //[[closeButton cell] setBackgroundColor:[NSColor clearColor]];
        [[closeButton cell] setHighlightsBy:NSChangeBackgroundCellMask|NSCellLightsByContents];
        //[[closeButton cell] setHighlightsBy:NSContentsCellMask];
        //[[closeButton cell] setShowsStateBy:0|NSContentsCellMask];

I also tried

[closeButton setButtonType:NSMomentaryChangeButton];

[[closeButton cell] setHighlightsBy:NSContentsCellMask];

with no results.

You can see the wrong behavior in the attached screenshots:

Bevel button overlaying a HUD window:
Bevel button overlaying a HUD window

Wrong bevel button background:
Wrong Bevel button background

  • 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-26T03:36:48+00:00Added an answer on May 26, 2026 at 3:36 am

    Creating button

    NSButton *myButton;
    myButton = [[NSButton new] autorelease];
    [myButton setTitle: @"Hello!"];
    [myButton sizeToFit];
    [myButton setTarget: self];
    [myButton setAction: @selector (function:)];
    

    Add button to window

    unsigned int styleMask = NSTitledWindowMask 
                               | NSMiniaturizableWindowMask;
    NSWindow *myWindow;
    myWindow = [NSWindow alloc];
    /*get the size of the button*/
    NSSize buttonSize;
    buttonSize = [myButton frame].size;
    /*set window content rect with the size of the button, and with an origin of our choice; (100, 100)*/
    NSRect rect;
    rect = NSMakeRect (100, 100, 
                       buttonSize.width, 
                       buttonSize.height);
    
    myWindow = [myWindow initWithContentRect: rect
                           styleMask: styleMask
                           backing: NSBackingStoreBuffered
                           defer: NO];
    [myWindow setTitle: @"my window"];
    /*replacing the default window content view with our button*/
    [myWindow setContentView: myButton];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have succeeded in creating a docset for my custom Cocoa Touch Static Library
I tried creating Radio Buttons using this example Creating a Cocoa radio button programatically
I'm creating a mainly GUI Cocoa app, but I want to create a command
How do I go about programmatically creating audio streams using Cocoa on the Mac.
Is there a way in Cocoa that is currently considered best practice for creating
I noticed that there is much repeated work to do when creating Cocoa source
I'm creating a backgrounded cocoa application. The only thing that it's missing is the
I am creating application for MAC using cocoa framework, I would like to know
I create a custom view in cocoa touch that is superclassed by UIView and
I'm creating a Cocoa Mac OS X app to install printers using a NSTask

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.