Re: Non-working NSButtonCells (can change state even is not enabled)
Re: Non-working NSButtonCells (can change state even is not enabled)
- Subject: Re: Non-working NSButtonCells (can change state even is not enabled)
- From: "Jean-Olivier Lanctôt-D." <email@hidden>
- Date: Sun, 26 Jan 2003 00:44:43 -0500
The thing is that, in my case, it can be changed in a
non-programatically way. e.g. via the interface (mouse clicks) eek!
On Sunday, January 26, 2003, at 12:32 AM, Jan Van Tol wrote:
Well, the docs have this to say about -setEnabled:
"However, you can still alter many attributes of a disabled cell
programmatically ( setState:, for instance, will still work)."
I believe it would be a great limitation if this wasn't the case for
many people.
-Jan Van Tol
On Saturday, January 25, 2003, at 10:29 PM, Jean-Olivier Lancttt-D.
wrote:
Hello list,
I have this weird problem with my NSButtonCells (NSSwitchButtons):
Even if they are NOT enabled, (e.g. GREYED OUT !!) I *can* change
their state (true/false).
it's very very very weird. here's my code.
###CODE
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if(aTableColumn==checkColumn) {
[aCell setState:[[NSNumber numberWithBool:![_unwantedPlugins
containsObject:[_allPlugins objectAtIndex:rowIndex]]] intValue]];
[aCell setEnabled:[[[_allPlugins objectAtIndex:rowIndex]
objectForKey:@"PNPluginIsEssential"] boolValue]];
}else{
NSString *titleText = [NSString stringWithFormat:@"%@
v.%@\n",[[_allPlugins objectAtIndex:rowIndex]
objectForKey:@"PNPluginName"],[[_allPlugins objectAtIndex:rowIndex]
objectForKey:@"PNPluginLatestVersion"]];
NSString *subtitleText = [[_allPlugins
objectAtIndex:rowIndex] objectForKey:@"PNPluginDescription"];
NSColor *titleTextColour;
if(rowIndex == [pluginsTable selectedRow]) {
titleTextColour = [NSColor whiteColor];
}else{
titleTextColour = [NSColor grayColor];
}
NSFont *titleTextFont = [NSFont
fontWithName:@"Helvetica-Bold" size:12.0];
NSFont *subtitleTextFont = [NSFont fontWithName:@"Helvetica"
size:11.0];
NSMutableAttributedString *niceString =
[[[NSMutableAttributedString alloc] initWithString:[titleText
stringByAppendingString:subtitleText]] autorelease];
NSDictionary *titleAttributes = [NSDictionary
dictionaryWithObjectsAndKeys:titleTextFont, NSFontAttributeName,
titleTextColour, NSForegroundColorAttributeName, nil];
NSDictionary *subtitleAttributes = [NSDictionary
dictionaryWithObjectsAndKeys:subtitleTextFont, NSFontAttributeName,
titleTextColour, NSForegroundColorAttributeName, nil];
[niceString setAttributes:titleAttributes
range:NSMakeRange(0,[titleText length])];
[niceString setAttributes:subtitleAttributes
range:NSMakeRange([titleText length],[subtitleText length])];
[aCell setAttributedStringValue:niceString];
[aCell setEnabled:NO];
}
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if(aTableColumn==checkColumn){
if([_unwantedPlugins containsObject:[_allPlugins
objectAtIndex:rowIndex]]){
[_unwantedPlugins removeObject:[_allPlugins
objectAtIndex:rowIndex]];
}else{
[_unwantedPlugins addObject:[_allPlugins
objectAtIndex:rowIndex]];
}
}
}
- (void)awakeFromNib {
NSButtonCell *switchCell = [[NSButtonCell alloc] init];
[switchCell setButtonType: NSSwitchButton];
[switchCell setImagePosition: NSImageOnly];
[checkColumn setDataCell:switchCell];
[switchCell release];
}
###END-CODE
So, even if I [aCell setEnabled:NO] the cell's state can BE CHANGED!
I don't think this problem is specific to my computer.. I think
there's a problem with my code.. but it seems logical ..
help me,please!
-- Jean-Olivier
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
-- Jean-Olivier
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.