Platforms to show: All Mac Windows Linux Cross-Platform

Back to DesktopNSCollectionViewControlMBS control.

Previous items

DesktopNSCollectionViewControlMBS.shouldDeselectItems(indexPaths() as NSIndexPathMBS) as NSIndexPathMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Asks the delegate object to approve the pending deselection of items.

indexPaths: The array of NSIndexPathMBS objects corresponding to the items deselected by the user.

Return the array of NSIndexPathMBS objects corresponding to the items that you want to be deselected. If you do not want any items deselected, return an empty set.

Use this method to approve or modify the items that the user tries to deselect. During interactive selection, the collection view calls this method whenever the user deselects items. Your implementation of the method can return the proposed set of index paths as-is or modify the set before returning it. You might modify the set to disallow the deselection of specific items.

This method is not called when you set the selection programmatically using the methods of the NSCollectionViewMBS class. If you do not implement this method, the collection view deselects the items specified by the indexPaths parameter.

DesktopNSCollectionViewControlMBS.shouldSelectItems(indexPaths() as NSIndexPathMBS) as NSIndexPathMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Asks the delegate to approve the pending selection of items.

indexPaths: The array of NSIndexPathMBS objects corresponding to the items selected by the user.

Returns the array of NSIndexPathMBS objects corresponding to the items that you want to be selected. If you do not want any items selected, return an empty array.

Use this method to approve or modify the items that the user tries to select. During interactive selection, the collection view calls this method whenever the user selects new items. Your implementation of the method can return the proposed set of index paths as-is or modify the set before returning it. You might modify the set to disallow the selection of specific items or specific combinations of items.

This method is not called when you set the selection programmatically using the methods of the NSCollectionViewMBS class. If you do not implement this method, the collection view selects the items specified by the indexPaths parameter.

DesktopNSCollectionViewControlMBS.sizeForItemAtIndexPath(layout as NSCollectionViewLayoutMBS, indexPath as NSIndexPathMBS) as NSSizeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Asks you for the size of the specified item.

collectionViewLayout: The layout object requesting the information.
indexPath: The index path of the item.

Return the size of the item. The width and height values must both be greater than 0. Items must also not exceed the available space in the collection view.

Implement this method when you want to provide the size of items in the flow layout. Your implementation can return the same size for all items or it can return different sizes for items. You can also adjust the size of items dynamically each time you update the layout. If you do not implement this method, the size of items is obtained from the properties of the flow layout object.

The size value you return from this method must allow the item to be displayed fully by the collection view. In the scrolling direction, items can be larger than the collection view because the remaining content can always be scrolled into view, but in the nonscrolling directions, items should always be smaller than the collection view itself. For example, the width of an item in a vertically scrolling collection view must not exceed the width of the collection view minus any section insets. The flow layout does not crop an item’s bounds to make it fit into the available space.

DesktopNSCollectionViewControlMBS.transitionLayout(fromLayout as NSCollectionViewLayoutMBS, toLayout as NSCollectionViewLayoutMBS) as NSCollectionViewTransitionLayoutMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Returns the transition layout object to use when performing an animated change between different layouts.

fromLayout: The current layout object of the collection view. This is the starting point for the transition.
toLayout: The new layout for the collection view.

Return the collection view transition layout object to use to perform the transition.

When changing layouts for a collection view, you can use this method to customize the transition layout object used to make the change. A transition layout object lets you customize the behavior of collection view elements when transitioning from one layout to the next. Normally, transitioning between layouts causes the assorted items and views to animate from their current locations directly to their new locations. By returning a custom transition object, you could have those elements follow a nonlinear path, use a different timing algorithm, or move items in response to touch events.

If you do not implement this method in your delegate object, the collection view uses a standard UICollectionViewTransitionLayout object for the transition.

Special Considerations
In OS X 10.11, this method is never called by the collection view.

DesktopNSCollectionViewControlMBS.updateDraggingItemsForDrag(draggingInfo as NSDraggingInfoMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Asks your delegate to update the dragging items during a drag operation.

draggingInfo: The current information for the drag operation. Use this object to iterate over the dragging items.

You can use this method to update the current drag items while a drag is in progress. Updating the drag items is optional, but you might use this method to change the image for an item. For example, you might change the image when the mouse hovers over a particular part of the collection view. Use the enumerateDraggingItems method of the draggingInfo parameter to iterate over the drag items and update them as appropriate.

DesktopNSCollectionViewControlMBS.validateDrop(draggingInfo as NSDraggingInfoMBS, byref proposedIndexPath as NSIndexPathMBS, byref dropOperation as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Validates whether a drop operation is possible at the specified location.

draggingInfo: The information about the drag operation.
proposedDropIndexPath: The index path at which the drop would occur. This parameter is passed by-reference and can be modified to change the proposed index path.
proposedDropOperation: The type of drop operation being proposed. This parameter is passed by-reference and can be modified to change the drop operation type.

Returns a value that indicates which dragging operation to perform. Return NSDragOperationNone to disallow a drop at the proposed location.

Although implementation of this method is optional, you must implement it to support drops onto the associated collection view. You must also call the collection view’s registerForDraggedTypes method to register the types of drops it supports. If you do not perform both of these actions, the collection view does not accept drops.

When an interactive drag operation occurs, the collection view calls this method to determine whether the current mouse location is a valid place to drop the content. This method may be called many times during the course of the drag operation. Your implementation should look at the proposed location and return a constant that reflects how the drop would be handled.
While validating the drop location, you can suggest a better drop location by updating the values in the proposedDropIndexPath and proposedDropOperation parameters. For example, you might suggest dropping the content before the specified item instead of on it. The collection view sets the proposedDropOperation parameter to DropOn when the mouse is closer to the middle of an item than to its edges; otherwise, it sets the parameter to DropBefore.

DesktopNSCollectionViewControlMBS.viewForSupplementaryElement(kind as String, indexPath as NSIndexPathMBS) as NSViewMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Asks your data source object to provide the supplementary view at the specified location in a section of the collection view.

kind: The kind of supplementary view to provide. The value of this string is defined by the current layout object associated with the collection view. Layouts may define additional views to add visual content that is unrelated to specific items.
indexPath: The index path that identifies the section in which to place the supplementary view.

Returns a configured view object. You must not return nil from this method.

Implement this method if the collection view’s layout object supports supplementary views. Your implementation is responsible for creating, configuring, and returning an appropriate view. You do this by calling the makeSupplementaryViewOfKind method of the collection view to retrieve an unconfigured view of the appropriate type. After receiving the view, update its properties and content using your app’s data structures and return it.
You do not need to set the location of supplementary views inside the collection view’s bounds. The collection view gets the view’s location and other layout-related attributes from the layout object during a separate step.

DesktopNSCollectionViewControlMBS.willDisplayItem(item as NSCollectionViewItemMBS, indexPath as NSIndexPathMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Notifies the delegate that the specified item is about to be displayed by the collection view.

item: The item being added.
indexPath: The index path of the item.

The collection view calls this method before adding new items to its content. You can use this method to track the addition of items and perform related tasks.

DesktopNSCollectionViewControlMBS.willDisplaySupplementaryView(view as NSViewMBS, elementKind as String, indexPath as NSIndexPathMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Notifies the delegate that the specified supplementary view is about to be displayed by the collection view.

view: The supplementary view being added.
elementKind: The type of the supplementary view. Layouts are responsible for defining the types of supplementary views they support.
indexPath: The index path associated with the supplementary view.

The collection view calls this method before adding new supplementary views to its content. You can use this method to track the addition of those views and perform related tasks.

DesktopNSCollectionViewControlMBS.willShowContextualMenu(menu as NSMenuMBS, NSEvent as NSEventMBS)   New in 24.1

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 24.1 ✅ Yes ❌ No ❌ No ❌ No
Will show contextual menu.

Your chance to modify the menu before it is shown, e.g. to add menu entries.

DesktopNSCollectionViewControlMBS.writeItems(indexPaths() as NSIndexPathMBS, Pasteboard as NSPasteboardMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event Cocoa Collection View MBS MacControls Plugin 21.5 ✅ Yes ❌ No ❌ No ❌ No
Places the data for the drag operation on the pasteboard.

indexPaths: The index paths of the items being dragged.
pasteboard: The pasteboard on which to place the drag data.

Return true if the drag operation can continue or no if you want to refuse the drag.

The collection view calls this method after it has determined that a drag should begin but before the drag operation has started. Your implementation of this method should do the following:

  • Declare the pasteboard types you support using the declareTypes method of the provided pasteboard object.
  • Write data to the pasteboard for each type you declare.
  • Return true from this event.

Previous items

The items on this page are in the following plugins: MBS MacControls Plugin.


The biggest plugin in space...