Re: Custom NSCell
Re: Custom NSCell
- Subject: Re: Custom NSCell
- From: Tilo Villwock <email@hidden>
- Date: Tue, 2 Mar 2010 09:26:53 +0100
Finally! That did the trick, thanks a lot! Does make sense though, the coordinates I used originally of course refer to the NSView insets and not to the ones from each NSCell, which is why all Strings were in same place.
Thanks again.
Tilo
Am 02.03.2010 um 08:56 schrieb Gustavo Pizano:
> Sean hello.
>
> Im not expert in this, but I had the same problem when making my own NSCell subclass to display a name and a picture next to it.. So in your NSCell subclass in the method - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView print(draw) your items in the cellFrame y position otherwise you will have all the data in the first row. I realize this because when I clicked where supposedly will be the <n> row, the table acutally selected the place where it was but of course nothing was there because all was drawn where the first rows resides.
>
>
> to calculate the point where to draw the rect for the name I do this:
>
> textPoint.x = cellFrame.origin.x + 5.0f;
> textPoint.y = cellFrame.origin.y +(cellFrame.size.height - nameSize.height)/2.0f - 5.0f ;
>
> I hope it helps
>
> Gustavo
>
> PS: if you have no ivars in your NSCell then there is no need to implement NSCopying, as if you have an ivar, like anNSString, then you must implement NSCopying because table uses copies of the cell,
>
> On Mar 2, 2010, at 1:09 AM, Sean McBride wrote:
>
>> On 3/1/10 8:45 PM, Tilo Villwock said:
>>
>>> In applicationDidFinishLaunching: I created an instance of my custom
>>> NSCell class and put it in place for the right column.
>>
>> Could you elaborate?
>>
>> I have found that I needed to set the custom cell in IB. You can drag a
>> custom cell from the library to the tableview's column then set the
>> class name to your cell subclass. But you can only do that in IB 3.2,
>> not earlier.
>>
>>> Any thoughts what might cause this behaviour? I don't assume it is
>>> necessary to create a new instance of my NSCell class for every row I
>>> have, right?
>>
>> No, NSTableView copies them.
>>
>> --
>> ____________________________________________________________
>> Sean McBride, B. Eng email@hidden
>> Rogue Research www.rogue-research.com
>> Mac Software Developer Montréal, Québec, Canada
>>
>>
>> _______________________________________________
>>
>> 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