<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColorPanel/dragColor(_:with:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColorPanel(cm)dragColor:withEvent:fromView:"
  },
  "title" : "dragColor(_:with:from:)"
}
-->

# dragColor(_:with:from:)

Drags a color into a destination view from the specified source view.

```
class func dragColor(_ color: NSColor, with event: NSEvent, from sourceView: NSView) -> Bool
```

## Parameters

`color`

The color to drag.

`event`

The drag event.

`sourceView`

The view from which the color was dragged.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true>

## Discussion

This method is usually invoked by the `mouseDown:` method of `sourceView`. The dragging mechanism handles all subsequent events.

Because it is a class method, [`dragColor(_:with:from:)`](/documentation/AppKit/NSColorPanel/dragColor(_:with:from:)) can be invoked whether or not the instance of `NSColorPanel` exists.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)