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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:47:45+00:00 2026-05-30T15:47:45+00:00

I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains

  • 0

I have a NSTableView which contains my custom NSCell subclass, IconCell.

The IconCell contains three elements : an image, text, and a button.

Here’s a simplified version of my drawing code (closeButton is the button):

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
    NSPoint cellPoint = cellFrame.origin;

    [controlView lockFocus];

    CGFloat buttonWidth = [closeButton frame].size.width;

    [someNSImage drawInRect:NSMakeRect(cellPoint.x, cellPoint.y, ICON_WIDTH, ICON_HEIGHT) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
    [someNSString drawInRect:NSMakeRect(cellPoint.x+ICON_WIDTH+PADDING, cellPoint.y, cellFrame.size.width - ICON_WIDTH - buttonWidth, cellFrame.size.height) withAttributes:someTextAttributes];
    [(NSButtonCell*)[closeButton cell] drawWithFrame:NSMakeRect(cellPoint.x + cellFrame.size.width - buttonWidth, cellPoint.y, buttonWidth, cellFrame.size.height) inView:controlView];

    [controlView unlockFocus];
}

The drawing part works fine and produces something like the following:

cell screenshot

which is what I want.

Moreover, I want one of two things to happen when the user interacts with the cell: if the user clicks anywhere on the cell, EXCEPT the close button, it should do actionA. If the user clicks on the close button, it should do actionB.

The problem I’m having is that the close button seems “invisible” — if I click on it, it doesn’t move (whereas a working button should show its pushed down state), and in general it behaves as if it wasn’t there, and actionA is triggered instead of actionB.

This is how I set the two actions:

[tableView setAction:@selector(actionA)];

and

[closeButton setAction:@selector(actionB)];

What am I doing wrong?

  • 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-30T15:47:46+00:00Added an answer on May 30, 2026 at 3:47 pm

    You’re just drawing a picture of the button in the cell. This isn’t the same thing as placing the actual button into the cell.

    Cells aren’t full views, so this is more complicated than you may think at first. If you really have to do this with cells, it’s explained here: NSButtonCell inside custom NSCell.

    But… if you can limit yourself to 10.7+, they’ve added view-based tableviews. These are much simpler, since you can put a full NSButton inside of your NSTableViewCellView. This is explained in the Table View Programming Guide. Highly recommended if you can limit yourself to 10.7+.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view-based NSTableView populated custom NSTabelCellView subclass, which are the lowest objects
I have a custom NSTableView subclass which is bound to a data source (an
I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core
I have an NSTableView which displays some information representing a custom object of mine.
I have an NSTableView of which one column contains NSPopUpButtonCell s. This column is
I have an NSTableView that contains a few columns that are populated with data.
I have a problem with sorting NSTableColumn contents. In my NSTableView there are three
I have an NSTableView which is bound to an NSDictionaryController. I have set this
I have an array controller which is bound to an nstableview. I also have
I have a NSTableView which has cells which can be edited, but when I

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.