Re: Checkbox in NSTableView (last word)
Re: Checkbox in NSTableView (last word)
- Subject: Re: Checkbox in NSTableView (last word)
- From: Lisa Zorn <email@hidden>
- Date: Fri, 25 Jan 2002 12:04:53 -0800 (PST)
For the record, Stephane is right and setting the image position to
NSImageOnly after setting the button type to NSSwitchButton works... I
don't know why it didn't before -- I must have been doing it in the
wrong order, because they all sound like attributes... =p Sorry 'bout
that. Heh. And thanks, Stephane.
-lisa
>
From: =?ISO-8859-1?Q?St=E9phane_Sudre?= <email@hidden>
>
Argh ! Just use the code I posted...
>
>
[tPrototypeCell setImagePosition:NSImageOnly];
>
>
It's not a bug, it's the designed behavior(tm).
>
>
The width of the Control is determined by the width of the Column as
>
stated in the original post.
>
>
What is not taken into consideration is that the Prototype of the
cell
>
is changed in the awakeFromNib (just a supposition). Since the
prototype
>
is changed, I don't see how the attributes could be kept.
>
>
Another issue is that there must be a call to [tPrototypeCell
>
setButtonType:NSSwitchButton];
>
>
If this selector is called, you can say bye bye to your Alignment
>
property even if it was saved by some kind of miracle.
>
>
Should you need to align the text (the text and not the control), you
>
would have to call [tPrototypeCell
setAlignment:NSCenterTextAlignment];
>
AFTER the setButtonType: Call.
>
>
But the most important fact is that the setAlignment: selector is
used
>
by the NSButton cell to align the TEXT not the control itself. It can
>
make the behavior look different from the one of the default cell
used
>
by NSTableView but the behavior is correct.
>
>
As stated in the documentation of NSCell:
>
>
setAlignment:
>
>
- (void)setAlignment:(NSTextAlignment)mode
>
>
Sets the alignment of text in the receiver. mode is one of five
>
constants: NSLeftTextAlignment, NSRightTextAlignment,
>
NSCenterTextAlignment,
NSJustifiedTextAlignment,NSNaturalTextAlignment
>
(the default alignment for the text).
>
>
So the easy way to center the checkbox is to call [tPrototypeCell
>
setImagePosition:NSImageOnly]; after having called [tPrototypeCell
>
setButtonType:NSSwitchButton];
>
>
Subclassing NSButtonCell is a time-killer.
>
>
Since I don'y have the AppKit source code under my eyes, what I'm
>
describing is just a guess from what I've been experiencing.
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com