• 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: programmatically creating a NSMatrix with a prototype cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programmatically creating a NSMatrix with a prototype cell


  • Subject: Re: programmatically creating a NSMatrix with a prototype cell
  • From: Bertil Holmberg <email@hidden>
  • Date: Sat, 20 Jun 2009 22:25:51 +0200

I do something similar here, perhaps you can spot some discrepancy?

// Instantiate a special buttonCell that can be drawn in color and configure it
CCDColoredButtonCell *colorCell = [[CCDColoredButtonCell alloc] init];
[colorCell setButtonColor:[NSColor clearColor]];
[colorCell setButtonType:NSMomentaryPushInButton];
[colorCell setBezelStyle:NSShadowlessSquareBezelStyle];
[colorCell setFont:[NSFont systemFontOfSize:15]];
[colorCell setAllowsMixedState:YES];
[colorCell setTarget:self];
[colorCell setAction:@selector(myAction:)];
[colorCell autorelease];

// Initial size of the buttons matrix
float mSize = 37 * squares - 2;

// Create the matrix of tri-state color capable buttons
protoMatrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(20, 60, mSize, mSize)
mode:NSHighlightModeMatrix
prototype:colorCell
numberOfRows:squares
numberOfColumns:squares];
[protoMatrix setIntercellSpacing:NSMakeSize(5, 5)];
[protoMatrix setCellSize:NSMakeSize(32, 32)];
[protoMatrix sizeToCells];
[protoMatrix autorelease];


	// Disable unused cells, set tag and title of the visible ones
	[self configureMatrix];

Create a NSTextFieldCell and customize it. Create a NSMatrix using
the "prototype" init version, and display it. All the custom
formatting is gone - all cells are vanilla NSTextFieldCells.

Loop through the matrix, and set each cell to a copy of the cell I
used as a prototype, using the "putCell..." method. Now it works fine.

_______________________________________________

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


  • Prev by Date: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by Date: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Previous by thread: Re: Crash in KVO when using -keyPathsForValuesAffecting<Key>
  • Next by thread: [WORKAROUND] Re: new NSTreeController bug in 10.5.7?
  • Index(es):
    • Date
    • Thread