Re: Creating NSMatrix of NSImageCells
Re: Creating NSMatrix of NSImageCells
- Subject: Re: Creating NSMatrix of NSImageCells
- From: Graham Cox <email@hidden>
- Date: Mon, 12 Oct 2009 09:58:15 +1100
On 12/10/2009, at 7:20 AM, PCWiz wrote:
I need to create an NSMatrix with NSImageCells bound to an array
controller. So the content of the NSMatrix is bound to an NSArray
(so there are as many NSImageCells in the matrix as there are
objects in the array), then the image path of the NSImageCells are
bound to a key called "iconPath" in the Array Controller.
And then when an image cell is clicked in the matrix, I need it to
perform an action. I know how to use bindings, and I have a concept
like this working in an NSTableView, but I have never used NSMatrix
before, so are there any good resources or sample code that would
help me get started with this?
Depending on how many images you anticipate needing to handle, you
might be better off looking at IKImageBrowserView, which loads images
lazily and on a second thread so it doesn't kill your UI response
while it's populating itself. It's slightly more complicated to use
than NSMatrix initially but chances are you'll probably want to end up
making the Matrix approach also load its images lazily and possibly on
another thread, which will be much more complicated than the already
built-in solution of IKImageBrowserView.
I'm not aware of any sample code specifically for NSMatrix and I've
never used it with bindings, but I have used it to create an array of
images - actually image-bearing buttons in my case - and it was
straightforward, even including lazy loading of the images (I did that
using a custom image button cell that fetches the image when it is
asked to draw the first time, so buttons that never actually appear
don't waste time loading images that are never displayed). What parts
of the NSMatrix class reference documentation are you having trouble
with?
--Graham
_______________________________________________
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