You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NSDragOperation represent which operations the dragging source can perform on dragging items.
There are several types of drag operations, and each one has a different purpose and visual cue.
Copy Operation .copy
What It Does: The item you're dragging will be copied. This means the original stays in place, and a duplicate is created in the new location.
When to Use: Use this when you want to create a copy of a file or item, without removing it from the original spot.
Cursor Symbol: The cursor shows a small "+" symbol to indicate that the item will be copied.
Example: Copying a file from one folder to another.
swift
Move Operation .move
The item will be moved from the original location to the new one. The original item disappears from its old location.
When to Use: Use this when you want to move an item to a new location without keeping it in the original place.
Cursor Symbol: The cursor shows the normal arrow (or sometimes an open hand), which indicates that the item will be moved.
Example: Moving an item within the same list or from one folder to another.
swift
Link Operation .link
A link (or alias) to the original item is created in the new location, but the actual item stays in the original place.
When to Use: Use this when you want to create a shortcut or link to the item without moving or copying it.
Cursor Symbol: The cursor shows a small arrow in the bottom corner, indicating that a link will be created.
Example: Creating a shortcut to a file in a different folder.
swift
Delete Operation .delete
The item will be deleted.
When to Use: Use this when you want to remove an item, like dragging a file to the Trash.
Cursor Symbol: The cursor shows a "X" symbol, indicating that the item will be deleted.
Example: Dragging files to the Trash to delete them.
Generic Operation .generic
This is a general-purpose operation where the action is not specifically a copy, move, or link.
When to Use: Use this for custom operations, like dragging a file into an app to open it without moving or copying it.
Cursor Symbol: This operation usually shows an app-specific cursor or no special symbol.
Example: Dragging a file into a photo-editing app to open it.
Every operation .every
The every operation allows all types of drag operations, such as copy, move, link, and any custom operations.
When to Use: Use this when you want to let the user choose any drag operation. It’s essentially a “catch-all” that means any valid drag operation is allowed at the drop target.
Cursor Symbol: The cursor symbol will change based on what the user chooses (for example, it could show a "+" symbol for copy or the normal arrow for move).
Example: You might use every in a drop area that can handle any kind of operation—copying, moving, or linking the dragged item.
None Operation []
This means no operation is allowed. The item cannot be dropped in the current location.
When to Use: Use this when the drop target doesn't support dragging, or the data being dragged is invalid for that area.
Cursor Symbol: The cursor shows a "no-entry" symbol, indicating that the item can't be dropped here.
Example: Trying to drag a file onto a part of an app that doesn’t accept files.
Sometimes, you might want to allow more than one operation at the same time. For example, you can allow both copy and move operations. The user can then choose which one to use by pressing special keys like the Option key.
[.copy,.move]
The text was updated successfully, but these errors were encountered:
NSDragOperation represent which operations the dragging source can perform on dragging items.
There are several types of drag operations, and each one has a different purpose and visual cue.
Copy Operation
.copy
Cursor Symbol: The cursor shows a small "+" symbol to indicate that the item will be copied.
swift
Move Operation
.move
The item will be moved from the original location to the new one. The original item disappears from its old location.
swift
Link Operation
.link
A link (or alias) to the original item is created in the new location, but the actual item stays in the original place.
swift
.delete
The item will be deleted.
Generic Operation
.generic
This is a general-purpose operation where the action is not specifically a copy, move, or link.
Every operation
.every
The every operation allows all types of drag operations, such as copy, move, link, and any custom operations.
None Operation
[]
This means no operation is allowed. The item cannot be dropped in the current location.
Sometimes, you might want to allow more than one operation at the same time. For example, you can allow both copy and move operations. The user can then choose which one to use by pressing special keys like the Option key.
The text was updated successfully, but these errors were encountered: