nscollectionviewitem

Cannot drag onto image in NSCollectionViewItem

[亡魂溺海] 提交于 2020-01-30 11:35:47
问题 I am designing a folder browser application similar to Finder. I want to enable users to drag files from outside the application and drop them onto a folder within my application, causing the dragged items to be added into that folder. My custom NSCollectionViewItem object, ArchiveCollectionViewItem , consists of a single NSImageView and a NSTextField . The image view is connected to the ArchiveCollectionViewItem 's imageView outlet and the text field is connected to the textField outlet. In

Get the index of view from which a button was clicked in a NSCollectionView

人盡茶涼 提交于 2020-01-06 07:16:50
问题 I have a NSCollectionView and I am adding my custom view which acts as NSCollectionViewItem for that collection view. In my collectionViewItem, I have a NSButton along with various other elements. I have a method onButtonClick which is connected to that button. Now, suppose I add 5 items of my collectonViewItem on to the collectionView. How can I get the index of the view from where the button was clicked? Inside onButtonClick , I tried following code but it always returns 0 regardless of

Resize view of NSCollectionViewItem

早过忘川 提交于 2020-01-04 09:16:50
问题 How do I programatically set the size of a view of an NSCollectionViewItem? I tried doing this in an NSCollectionView subclass: @implementation CustomCollectionView - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { NSCollectionViewItem *newitem = [[self itemPrototype] copy]; [newitem setRepresentedObject:object]; NSView *itemview = [newitem view]; [itemView setFrame:NSMakeRect([itemView frame].origin.x, [itemView frame].origin.y, [itemView frame].size.width, 500)]; return

Selection Highlight in NSCollectionView

好久不见. 提交于 2019-12-17 17:37:23
问题 I have a working NSCollectionView with one minor, but critical, exception. Getting and highlighting the selected item within the collection. I've had all this working prior to Snow Leopard, but something appears to have changed and I can't quite place my finger on it, so I took my NSCollectionView right back to a basic test and followed Apple's documentation for creating an NSCollectionView here: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/CollectionViews

NSCollectionView cell order changes on view change

白昼怎懂夜的黑 提交于 2019-12-11 02:14:29
问题 I have a macOS application that contains a tab bar design (ie: Tweetbot). There are 4 tabs that are linked to 4 different view controllers. The initial view controller (view one) contains a NSCollectionView which displays 3 cells horizontally. This all works fine, however when I switch to another view controller and then come back to the initial view controller, the order of the collection view changes for no reason. I am not making ANY changes to the data source (which is a NSMutableArray )

Binding to NSCollectionViewItem crashes Xcode

吃可爱长大的小学妹 提交于 2019-12-10 10:13:20
问题 Using XCode 4.1 I've come across a crash whenever I try to use a CollectionView. These are the steps I'm doing: From a new project, edit the MainMenu.nib file. Add an NSCollectionView to the window, which also adds a Collection View Item, and a new View In the new View Add a control like an NSTextField Select the control, and switch the inspector to the binding pane. Attempt to bind something to the Collection View Item. Once the Collection View Item is selected in the dropdown menu, an

Resizing NSCollectionView to fit inner items?

我的未来我决定 提交于 2019-12-09 23:31:50
问题 How can I resize my NSCollectionView to fit the size of all my items ? I tried something like that : float height=0; for(int i=0;i<[drives count]; i++) { height += [[[collectionView itemAtIndex:i] view] bounds].size.height; } NSLog(@"%lg", height); [[self view] setBoundsSize:NSMakeSize(300, height)]; and all I got was a horrible result : the collectionView was distorted. It was previously smaller than the parent view and with that it expanded to fill the parent view. NB : I removed the

How do you initialize a NSCollectionViewItem?

假装没事ソ 提交于 2019-12-07 18:55:05
问题 I am trying to setup an NSCollectionView that has custom drawing in the individual NSCollectionViewItem views. I have an image that I need to draw in each view, but I cannot link the view back to the NSCollectionViewItem subclass in Interface Builder. Is there an init method I can use with my NSCollectionViewItem in order to perform initialization operations? I tried to implement copyWithZone, but I was doing something wrong because I got some eternal loop. Currently, the only opportunity I

How do you initialize a NSCollectionViewItem?

[亡魂溺海] 提交于 2019-12-06 05:49:07
I am trying to setup an NSCollectionView that has custom drawing in the individual NSCollectionViewItem views. I have an image that I need to draw in each view, but I cannot link the view back to the NSCollectionViewItem subclass in Interface Builder. Is there an init method I can use with my NSCollectionViewItem in order to perform initialization operations? I tried to implement copyWithZone, but I was doing something wrong because I got some eternal loop. Currently, the only opportunity I have found to make my connections to the view are after the selection has changed using -(void

Binding to NSCollectionViewItem crashes Xcode

淺唱寂寞╮ 提交于 2019-12-06 01:32:39
Using XCode 4.1 I've come across a crash whenever I try to use a CollectionView. These are the steps I'm doing: From a new project, edit the MainMenu.nib file. Add an NSCollectionView to the window, which also adds a Collection View Item, and a new View In the new View Add a control like an NSTextField Select the control, and switch the inspector to the binding pane. Attempt to bind something to the Collection View Item. Once the Collection View Item is selected in the dropdown menu, an "Internal Error" dialog appears. Attempting to continue from this dialog makes the binding pane disappear