• 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: bindings for nsmatrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bindings for nsmatrix


  • Subject: Re: bindings for nsmatrix
  • From: Byron Wright <email@hidden>
  • Date: Sun, 6 Mar 2005 16:53:55 -0800

you don't need a custom NSMatrix, what you need is an IBOutlet in a controller class to it so you can access it in your controllers awakeFromNib method and programmatically bind it. If you do have a custom NSMatrix view you can set it's custom NSCell class in it's initWithFrame method. Something like this :

- (id) initWithFrame : (NSRect ) frame
{
	if( self = [super initWithFrame:frame
					mode:NSListModeMatrix
					cellClass:[CFCThumbCell class]
					numberOfRows:1
					numberOfColumns:5] )
	{

		[self setCellSize:NSMakeSize(160,140)];
		[self setIntercellSpacing:NSMakeSize(15,15)];
		[self setAllowsEmptySelection:YES];
		[self setSelectionByRect:NO];
	}
	return self;
}


or since you have an IBOutlet to it already you could simply call it's setCellClass method.


[matrixInstance setCellClass:[MyCustomCell class]];


If you want to use a custom NSMatrix in you would drag an NSMatrix onto your UI then goto the the info panel -> custom class and select your custom class from the list. If you have a constructor similar to the initWithFrame example above then your NSMatrix will already use your custom cell class. You will still have to programmatically perform the bindings as far as I know. Also, be sure to go to classes in the main menu and read your custom NSMatrix header file so it shows up in the Custom Class list :).


Hope that helps,
Byron

On Mar 5, 2005, at 9:24 PM, Emory Smith wrote:

hi byron,

so does this mean that i must have a custom NSMatrix subclass?

i actually did create one, just to test whether this would work and found that it did. its just that to do so seems extraneous, since the only reason for it would be to expose the bindings that are already present in NSMatrix.

also, how do you programmatically associate an NSMatrix (or subclass thereof) with a custom cell? i would assume (since MSMatrix is a subclass of NSControl) that you would use setCellClass. the problem is that i want to create the matrices (matrixes?) in IB by alt-dragging and im not sure how to tell IB "you should use this particular subclass of NSMatrix and expose these particular bindings whenever i alt-drag on this particular custom subclass of NSControl". seems like something of that sort must be feasible since the set of bindings available to a matrix of text-fields cells is different than that available to a matrix of button cells.

thanks,
emory

On Mar 5, 2005, at 6:59 PM, Byron Wright wrote:

I recently did something like this. I think you have to do it programmatically. Here is some example code from my app.

//bindingOptions = NSMutableDictionary
[bindingOptions setObject:[NSNumber numberWithBool:YES] forKey:@"NSInsertsNullPlaceholder"];
[bindingOptions setObject:[NSNumber numberWithBool:YES] forKey:@"NSRaisesForNotApplicableKeys"];

//thumbGrid is an instance of my custom NSMatrixView. You can do this in awakeFromNib. I have custom NSButtonCells associated with my custom NSMatrixView. "
[thumbGrid bind:@"content" toObject: self withKeyPath:@"arrangedObjects" options:bindingOptions];


//bind cells to thumbnailImage
[thumbGrid bind:@"contentValues" toObject: self withKeyPath:@"arrangedObjects.thumbnailImage" options:bindingOptions];


Hope this helps.

Byron

On Mar 5, 2005, at 5:20 PM, Emory Smith wrote:

hello,

i have a custom control / cell pair for which i have created an IB palette item. i drag my custom control from the palette to my window and alt-drag it to get matrix. i have added some custom bindings to my nscell subclass and these work great, the problem is that i have to select each cell of the matrix and bind it individually.

i would like to use the "standard" matrix bindings (content, selectedObjects, etc.) with my matrix of custom cells, but IB does not show these bindings in the inspector.

what more do i need to do to expose these bindings in IB for a matrix containing custom cells?

thanks,
emory

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden








Byron Wright
Software Developer
Siemens Business Services Media
(formerly BBC Technology)
Mobile: 206-227-4645
Email: email@hidden
www.bbctechnology.com
www.siemens.co.uk/sbs

This e-mail (and any attachments) contains confidential information and is for the exclusive use of the addressee/s. Any views contained in this e-mail are not the views of Siemens Business Services Media Holdings Ltd unless specifically stated. If you are not the addressee, then any distribution, copying or use of this e-mail is prohibited. If received in error, please advise the sender and delete/destroy it immediately. We accept no liability for any loss or damage suffered by any person arising from use of this e-mail/fax. Please note that Siemens Business Services Media Holdings Ltd monitors e-mails sent or received. Further communication will signify your consent to this.

Siemens Business Services Media Holdings Ltd
Registered No: 04128934 England
Registered Office: Siemens House, Oldbury, Bracknell, Berkshire, RG12 8FZ


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >bindings for nsmatrix (From: Emory Smith <email@hidden>)
 >Re: bindings for nsmatrix (From: Byron Wright <email@hidden>)
 >Re: bindings for nsmatrix (From: Emory Smith <email@hidden>)

  • Prev by Date: Quick polymorphism and subclassing question
  • Next by Date: Re: Creating a JavaVM with JNI & Re:JavaBridge
  • Previous by thread: Re: bindings for nsmatrix
  • Next by thread: Re: bindings for nsmatrix
  • Index(es):
    • Date
    • Thread