nscollectionview

NSCollectionView Drag and Dropping: Most Delegate Events Not Getting Called

不想你离开。 提交于 2019-12-04 06:30:15
I have an NSCollectionView bound to an NSArrayController. I want to get drag and drop working, so I create a delegate and implement the methods -(BOOL)collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent*)event -(BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id < NSDraggingInfo >)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation -(NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id < NSDraggingInfo >)draggingInfo proposedIndex:(NSInteger *

Example for Drag and Drop inside NSCollectionView

大憨熊 提交于 2019-12-04 05:33:44
问题 I would like to move items inside a NSCollectionView using its drag and drop delegate methods. I get it working until the item should get dropped. There is no destination indicator (gap) and when releasing the mouse the item is bouncing back. The delegates validateDrop and acceptDrop never gets called. The CollectionViewItems are showing data from custom objects: func collectionView(_ collectionView: NSCollectionView, canDragItemsAt indexPaths: Set<IndexPath>, with event: NSEvent) -> Bool {

NSCollectionViewItem never instantiate

不羁的心 提交于 2019-12-04 01:38:25
问题 I'm a bit lost here: I created a button acting like a colorPicker: clicking on it shows a collectionView in a popover. I first did it with a nib fil containing a view + the collectionView (embedded in as scrollView + a clipView). The stuff works just fine. As the nib file is very simple (and to improve my coding skills in designing views programmatically), I decided to get rid of the nib file and write the missing part in code. The thing is, I manage to get the job done except for the content

NSCollectionView does not scroll items past initial visible rect

£可爱£侵袭症+ 提交于 2019-12-04 01:22:08
问题 I'm running into an issue with an existing app while trying to fix a few outstanding macOS 10.13 bugs. I have a small NSCollectionView that looks similar to the small monthly calendar in the Calendar app. It displays days and scrolls vertically on click. However, on macOS 10.13 the collection view only displays a few rows and does not scroll. I've verified that the data source is being called correctly and it does try to load additional items - but doesn't scroll to them. I've created a small

NSCollectionViewFlowLayout - left alignment

大兔子大兔子 提交于 2019-12-03 20:21:33
NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? Obliquely Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect(rect: CGRect) -> [NSCollectionViewLayoutAttributes] { let defaultAttributes = super

Is there a way to have varying views in an NSCollectionView?

我怕爱的太早我们不能终老 提交于 2019-12-03 15:07:06
I am wanting something similar to how iWork has the template selection screen for Pages when you can select different templates, and each view contains different info has difference sizes etc. I have tried subclassing NSCollectionView and determining which view to display using the newItemForRepresentedObject method (as opposed to using itemPrototype view Interface Builder), but it for some reason doesn't position the views correctly, and it does not show the correct number of views for the number of items present. Here is my code. I was hoping someone may have a better way to do this, or an

10.11 NSCollectionView - determining cell size dynamically

故事扮演 提交于 2019-12-03 12:28:01
问题 AppKit Release Notes for OS X v10.11 suggests that collection view items can be resized on a per-item basis: Item size can be determined globally for all of a CollectionView’s items (by setting an NSCollectionViewFlowLayout’s “itemSize” property), or can be varied from one item to the next (by implementing -collectionView:layout:sizeForItemAtIndexPath: on your CollectionView’s delegate). In my case, my CollectionViewItem consists of a single label that contains a string of varying length. I'm

10.11 NSCollectionView - determining cell size dynamically

爱⌒轻易说出口 提交于 2019-12-03 02:53:07
AppKit Release Notes for OS X v10.11 suggests that collection view items can be resized on a per-item basis: Item size can be determined globally for all of a CollectionView’s items (by setting an NSCollectionViewFlowLayout’s “itemSize” property), or can be varied from one item to the next (by implementing -collectionView:layout:sizeForItemAtIndexPath: on your CollectionView’s delegate). In my case, my CollectionViewItem consists of a single label that contains a string of varying length. I'm using the NSCollectionView to display an array of strings, as NSStackViews don't support array

Cannot get drag and drop to work onto NSCollectionView

拥有回忆 提交于 2019-12-02 11:37:42
There is probably a simple mistake that I'm making, but I simply cannot get dropping of files onto an NSCollectionView to work even in the most basic way. In a test project, I have an NSCollectionView on a window, and the view controller is both its delegate and data source. I want to be able to drag files from the Finder onto this collection view. From reading the docs, all I should have to do is: Register for dragged type(s): - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSLog(@"Registering dragged types for collection view: %@", self

Cannot get drag and drop to work onto NSCollectionView

余生颓废 提交于 2019-12-02 07:55:41
问题 There is probably a simple mistake that I'm making, but I simply cannot get dropping of files onto an NSCollectionView to work even in the most basic way. In a test project, I have an NSCollectionView on a window, and the view controller is both its delegate and data source. I want to be able to drag files from the Finder onto this collection view. From reading the docs, all I should have to do is: Register for dragged type(s): - (void)viewDidLoad { [super viewDidLoad]; // Do any additional