{
   "description" : "The DndView is a subclass of QDragView, implementing additional functionality. When a drag-and-drop is performed between two such views, setting one's value will update the other's as well. Use the 'value' method to get or set the value of a view.\r\n\r\nWhen creating a new instance of the view, you can pass in the 'type' argument, which can be \\source, \\sink, or \\both, defining what will be the role of the view.",
   "ancestor_list" : [],
   "name" : "Drag and drop views that share data",
   "author" : "Jakob Leben",
   "code" : "SharedDndData\r\n{\r\n    var <value;\r\n    \r\n    *new { arg val; ^super.newCopyArgs(val) }\r\n\r\n    value_ { arg val;\r\n        value = val;\r\n        this.changed(\\value);\r\n    }\r\n\r\n    asString { ^value.asString; }\r\n}\r\n\r\nDndView : QDragView\r\n{\r\n    var views;\r\n\r\n    *new { arg parent, bounds, type = \\both;\r\n        var view = super.new(parent, bounds);\r\n        view.onClose = { view.object.removeDependant(view) };\r\n        if (type === \\source or: (type === \\both)) {\r\n            view.beginDragAction = { view.object };\r\n        };\r\n        if (type === \\sink or: (type === \\both)) {\r\n            view.canReceiveDragHandler = true;\r\n            view.receiveDragHandler = { view.object = View.currentDrag }\r\n        };\r\n        ^view;\r\n    }\r\n\r\n    object_ { arg new_obj;\r\n        object.removeDependant(this);\r\n        object = new_obj;\r\n        object.addDependant(this);\r\n        this.string = object.asString;\r\n    }\r\n\r\n    value { ^this.object.value }\r\n\r\n    value_ { arg new_val;\r\n        if (this.object.isNil) {\r\n            this.object = SharedDndData(new_val);\r\n        }{\r\n            this.object.value = new_val;\r\n        }\r\n    }\r\n\r\n    update { arg caller;\r\n        if (caller === object) { this.string = this.object.asString }\r\n    }\r\n}",
   "id" : "1-4Hb",
   "is_private" : null,
   "labels" : [
      "drag",
      "drop",
      "auto",
      "update",
      "shared"
   ]
}
