Re: IB outlets and NSCollectionViews
Re: IB outlets and NSCollectionViews
- Subject: Re: IB outlets and NSCollectionViews
- From: Daniel Vollmer <email@hidden>
- Date: Sun, 25 May 2008 11:43:27 +0200
On May 23, 2008, at 17:48, David Carlisle wrote:
I solved a similar problem when putting a pop up menu into a
collectionView item.
There might be an easier way, but I assume that to put a button in a
collectionViewItem, the button would have to send a message to a
subclass of NSCollectionViewItem, which you would then cause to send
a similar message along with a copy of the representedObject to a
subclass of NSCollectionView. (Note that an NSCollectionViewItem
knows both its representedObject and its NSCollectionView.) You
would write your NSCollectionView subclass to have an outlet for
File's Owner, so you could forward the message from the button to
File's Owner, which could then take some action on the
representedObject.
On May 23, 2008, at 8:01 AM, Marcel Borsten wrote:
Could you give a bit more information on how you solved this. I'm
trying to do something similar, but I can't get it to work.
Hm ...I had to bind it to a NSCollectionItemView subclass that
routes to the AppController.
cheers
--
Torsten
On Apr 7, 2008, at 18:04, Torsten Curdt wrote:
Hm ...I was trying to bind a button inside a NSCollectionItemView
view to an action in my AppController. This obviously does not
work.
Of course the view is only a prototype that gets cloned per item
in the collection but I was expecting to just get the instance
passed on the call.
So how would I need to do something like this?
cheers
--
Torsten
For sending button actions messages, don't bother with binding
explicitly to your AppController, just send the required selector to
firstResponder and pick that up in your AppController (it should
already get these messages if you start from an NSDocument-based
application IIRC).
As for accessing properties of your represented object in your view, I
simply do the following in my view, where cvItem is an IBOutlet to the
prototype NSCollectionViewItem:
- (void)awakeFromNib
{
[self bind:@"plotRoot" toObject:cvItem
withKeyPath:@"representedObject" options:nil];
[self bind:@"isSelected" toObject:cvItem withKeyPath:@"selected"
options:nil];
}
This only binds the prototype view, but the bindings are properly set
to the instantiated object by the obscure NSView-copying via NSCoder
shenanigans (as described on cocoadev).
Daniel.
_______________________________________________
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