• 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: NSPopUpButtonCell's in NSHeaderView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButtonCell's in NSHeaderView


  • Subject: Re: NSPopUpButtonCell's in NSHeaderView
  • From: PGM <email@hidden>
  • Date: Sat, 4 Aug 2007 00:53:10 +0200


On 3 Aug 2007, at 07:09, William Zumwalt wrote:

I have a project where I've been working on trying to get
NSPopUpButtonCell's working in the header of an NSTableView for some time
but get some strange results. I've made several attempts at working it out
on the list, but to no avail.



I've simplified only the problem into a smaller project and was wondering if
anyone could take a look at it and see if I am doing something wrong. It
compiles and reproduces the problem easily. The problem is that one too many
columns is created and when a selection is made from the tables header cell,
it doesn't clear the text in the cell, it just overlays text on top of text.



If so, please email me and I can send a *.tar.gz of the test code.

The extra column only appears when the existing columns are not wide enough to fill the entire view. So it is not really a column, but simply a trick to fill up the empty space. However, this extra column is simply implemented by copying the headercell of the last real column. This it may have its good sides, e.g. when using a completely customised UI, but is in most cases a nuisance when using a custom headerCell. As the ghost headercell is a copy of the last real header, if you have an NSCell class, you may have to implement copyWithZone: otherwise you can get nasty crashes.


I have my own NSTableHeaderCell subclass that draws a switchButton in the header, and I have circumvented the problem of the ghost column by overriding drawInteriorWithFrame:inView: and in it, I make a simple test:

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *) controlView
{
[super drawInteriorWithFrame:cellFrame inView:controlView];


//don't draw if value is not set (otherwise empty column at end is also drawn)
//in your case you may not be able to use the title, but possibly you can find another variable to test
if([[self title] length]){
//do custom drawing here, I have an NSButton instance for which I set a suitable frame relative to cellFrame
//then I use [controlView addSubview:switchButton];
}


   //don't do any custom drawing here
}

I am considering to make the code available on my website. However, I also sometimes have similar drawing glitches of my custom headerCell, so if somebody knows the answer to that problem, I would like to hear from them, and I think the iTunes-developers would also be glad to know the solutionl ;-).

Hope this helps, Patrick

_______________________________________________

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: 
 >NSPopUpButtonCell's in NSHeaderView (From: "William Zumwalt" <email@hidden>)

  • Prev by Date: Re: [OT] "Fluent Interface"? Welcome to NeXT
  • Next by Date: Wrong undo behavior while runModalForWindow:
  • Previous by thread: NSPopUpButtonCell's in NSHeaderView
  • Next by thread: Loading NSFont from file
  • Index(es):
    • Date
    • Thread