• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSButtonCell in NSTableView doesn't receive setHighlighted:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell in NSTableView doesn't receive setHighlighted:


  • Subject: Re: NSButtonCell in NSTableView doesn't receive setHighlighted:
  • From: Sebastian Morsch <email@hidden>
  • Date: Sun, 6 Jan 2008 10:31:08 +0100

Thanks for your reply Ken, I link against 10.5 and your suggestion worked great! Since I really don't want my buttons look pressed in selected rows as you pointed out, I don't consider it a bug anymore. It's maybe more something like a "historically derived little flaw", so whatever.

Thanks!

Sebastian



Am 05.01.2008 um 19:29 schrieb Ken Ferry:

It's not a big deal of course, but since setHighlight: is a superclass
method from NSCell it seems strange to me that the table doesn't treat
all cells equally. Is this expected behaviour or is it worth filing a
bug?

It's always fine to file a bug, but this probably isn't going to change. There are too many clients that rely on the existing behavior, whether they're aware of it or not.

The problem is that 'highlight' does not have a sufficiently defined
meaning at the NSCell level.  Different cells use the flag in
different ways, which makes it difficult for a client that deals with
cells generically to use it.  For button and button-like objects,
highlighted means pressed.  You probably don't want your buttons to
look pressed in selected table rows.  NSTableView, sadly, special
cases those cells types that should not be highlighted in selected
rows.

If you can require 10.5, I suggest you take a look at -[NSCell
backgroundStyle] and related API instead.  The most common reason for
a cell wanting to know that it's in a selected row is to draw
differently.  For example, text drawn on top of selected rows of a
table should be white.  In this case, and usually, it isn't really
that the cell is in a selected table row that's important, it's that
it's being drawn on top of something dark.  The text needs to be white
for contrast.

This information is what the background style API gives you.  It lets
you know some very high level information about the context where the
cell is being drawn, that it's on something 'light', 'dark', 'raised'
or 'lowered'.  Please see the AppKit Leopard release notes for more
detail, and also the NSCell documentation.

-Ken
Cocoa Frameworks

On Jan 5, 2008 6:24 AM, Sebastian Morsch <email@hidden> wrote:
Hi,

I just found out that an NSButtonCell that sits in an NSTableView
doesn't receive the setHighlighted: message from the table when it's
displayed for a selected row. In the case of NSImageCell and
NSTextFieldCell it DOES happen, they both receive that message from
the table's preparedCellAtColumn:row: method.

I couldn't find an answer to this in previous posts.

I worked around this by subclassing NSTableView and overriding that
method to make sure all cells get the setHighlighted:

- (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row
{
       NSCell* cell = [super preparedCellAtColumn:column row:row];

       [cell setHighlighted:(row == [self selectedRow])];

       return cell;
}


It's not a big deal of course, but since setHighlight: is a superclass
method from NSCell it seems strange to me that the table doesn't treat
all cells equally. Is this expected behaviour or is it worth filing a
bug?



Sebastian _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSButtonCell in NSTableView doesn't receive setHighlighted: (From: Sebastian Morsch <email@hidden>)
 >Re: NSButtonCell in NSTableView doesn't receive setHighlighted: (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: thread protocol modifiers
  • Next by Date: Re: Simple bindings problem
  • Previous by thread: Re: NSButtonCell in NSTableView doesn't receive setHighlighted:
  • Next by thread: NSMatrix: does it have an delegate method, to implement when a cell is clicked
  • Index(es):
    • Date
    • Thread