• 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: Need recommendations for best way to build a custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need recommendations for best way to build a custom view


  • Subject: Re: Need recommendations for best way to build a custom view
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 19 Feb 2009 18:16:27 -0500

Thanks Kyle

-tableView:isGroupRow: gets me about 80 percent of the way there, but I'm still having a few issues.

- My "tableView:dataCellForTableColumn:row:" method is set up to return data cells correctly (I think) but the project name is editable and I don't want it to be.
- The project name is still truncated to the width of the "pageNumber" column width even when it is defined as a group cell.
- When arrow scrolling to the group cell (project), it doesn't highlight in blue. The gray background gets slightly darker but I would like it to be the blue embossed color of group cells


Here's how I define the project and page number cells

- (void) initTextCells
{
	pageNumberCell		= [[NSTextFieldCell alloc] init];
	[pageNumberCell setBordered: NO];
	[pageNumberCell setBezeled: NO];

	projectNameCell		= [[NSTextFieldCell alloc] init];
	[projectNameCell setBordered: NO];
	[projectNameCell setBezeled: NO];
	[projectNameCell setEditable: NO];

	dummyCell			= [[NSTextFieldCell alloc] init];
	[dummyCell setBordered: NO];
	[dummyCell setBezeled: NO];
	[dummyCell setEditable: NO];

}

And here's my tableView:dataCellForTableColumn:row: delegate methods

///* may use later later
- (NSCell *) tableView:(NSTableView *) inTableView
dataCellForTableColumn:(NSTableColumn *) inTableColumn
row:(NSInteger) inRow
{
if ([[inTableColumn identifier] isEqualToString: @"delete"])
{
NSString *cellType = [[[testController arrangedObjects] objectAtIndex: inRow] objectForKey: @"cell_type"];

if ([cellType isEqualToString: @"project"])
return addCell;
else
return deleteCell;
}
else if ([[inTableColumn identifier] isEqualToString: @"page_number"])
{
NSString *cellType = [[[testController arrangedObjects] objectAtIndex: inRow] objectForKey: @"cell_type"];

if ([cellType isEqualToString: @"project"])
return projectNameCell;
else
return pageNumberCell;
}
else if ([[inTableColumn identifier] isEqualToString: @"master"])
{
NSString *cellType = [[[testController arrangedObjects] objectAtIndex: inRow] objectForKey: @"cell_type"];

if ([cellType isEqualToString: @"project"])
return dummyCell;
else
return masterPageCell;
}
else
return [inTableColumn dataCellForRow: inRow];
}


- (BOOL) tableView:(NSTableView *) inTableView
isGroupRow:(NSInteger) inRow
{
NSString *cellType = [[[testController arrangedObjects] objectAtIndex: inRow] objectForKey: @"cell_type"];

return [cellType isEqualToString: @"project"] ? YES : NO ;
}



One thing I notice is that even though the "projectNameCell" and "dummyCell" are defined as not edtable, they are in editable the table. I suspect it's just ignoring my tests inside tableView:dataCellForTableColumn:row: and just returning a generic text cell.


How do I get the editability correct and get project name field to be wider than the page number field?


On Feb 19, 2009, at 4:34 PM, Kyle Sluder wrote:

On Thu, Feb 19, 2009 at 4:17 PM, Ken Tozier <email@hidden> wrote:
Seems simple enough but I can't use tables because columns are a single
width and project names are much longer than page numbers. What I end up
with are ridiculously long page number fields to display short numbers like
1, 2, 3, etc. I had a small bit of success, at least with respect to the way
items were layed out, using custom NSCells, but this quickly gets mired in
dozens of overrides and hit testing parts of the cell to make the subcells
work.

Can you afford to target Leopard-only? If so, you can use full-width cells for your project rows. Return the cell in your delegate's -tableView:dataCellForTableColumn:row: method when nil is passed for the tableColumn argument. You might also want to return YES for -tableView:isGroupRow: for this row.

--Kyle Sluder

_______________________________________________

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


  • Follow-Ups:
    • Re: Need recommendations for best way to build a custom view
      • From: Kyle Sluder <email@hidden>
References: 
 >Need recommendations for best way to build a custom view (From: Ken Tozier <email@hidden>)
 >Re: Need recommendations for best way to build a custom view (From: Kyle Sluder <email@hidden>)

  • Prev by Date: How to re-create Finders File Copy
  • Next by Date: Re: How to re-create Finders File Copy
  • Previous by thread: Re: Need recommendations for best way to build a custom view
  • Next by thread: Re: Need recommendations for best way to build a custom view
  • Index(es):
    • Date
    • Thread