• 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: Non-working NSButtonCells (can change state even is not enabled)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-working NSButtonCells (can change state even is not enabled)


  • Subject: Re: Non-working NSButtonCells (can change state even is not enabled)
  • From: Jan Van Tol <email@hidden>
  • Date: Sat, 25 Jan 2003 23:32:28 -0600

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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Non-working NSButtonCells (can change state even is not enabled)
      • From: "Jean-Olivier Lanctôt-D." <email@hidden>
References: 
 >Non-working NSButtonCells (can change state even is not enabled) (From: "Jean-Olivier Lanctôt-D." <email@hidden>)

  • Prev by Date: Re: NSBrowser: so very, very broken
  • Next by Date: getting key codes
  • Previous by thread: Non-working NSButtonCells (can change state even is not enabled)
  • Next by thread: Re: Non-working NSButtonCells (can change state even is not enabled)
  • Index(es):
    • Date
    • Thread