1.66(2022年3月)版本引入A
但是,在对象说:
拖动降落控制器{@link treedraganddropcontroller.handledrag handledrag
}可以将其他MIME类型添加到数据传输中。这些附加的MIME类型仅在 handledRop
中包括在同一拖放控制器中的元素时。
。
这是否意味着您无法拖动&在自定义树视图之间放置,因为它们通常具有自定义拖动&每个视图下降控制器?或者您打算重新使用阻力&树视图之间的下降控制器,以启用拖动&在视图之间落下?
我尝试了各种组合,并且无法成功获得完整的阻力&在两个树视图之间掉落。在某些情况下,我确实看到了控制台上的错误,但仅此而已。
The 1.66 (March 2022) release introduces a TreeDragAndDropController API which allows for handling drag & drop events for custom tree views.
However in the docs for the DataTransfer object is says:
Drag and drop controllers that implement {@link TreeDragAndDropController.handleDrag handleDrag
} can add additional mime types to the data transfer. These additional mime types will only be included in the handleDrop
when the the drag was initiated from an element in the same drag and drop controller.
Does this mean that you cannot drag & drop between custom tree views as they would typically have a custom drag & drop controller per view? Or that you're meant to re-use a drag & drop controller between tree views in order to enable dragging & dropping between views?
I have tried various combinations and been unsuccessful in getting a full drag & drop between two tree views. I do see an error in the console on drop in some situations but that is about it.
发布评论
评论(1)
我花了一段时间才弄清楚如何获得Drag&在两个不同的树视图之间工作。对我来说,问题是:
dragmimetypes < / code>的误解 /用法。
treedatatransfer.set()< / code>的目的 /用法。
这可能是通过示例最好描述的。
让我们假设我们只会从 treeview_a 拖动,我们只能落到 treeview_b 上。
对于 treeview_a
dropmimetypes
可以是一个空数组,因为我们不希望收到任何滴滴。dragmimetypes
需要包括我们要落到的树景的MIME类型(即 treeview_b )。这里有一个警告,此必须以application/vnd.code.tree。因此,在此示例中,它将读取类似的内容:
wandledrag()
方法需要使用目标树视图的MIME类型( treeview_b )设置,(请记住lowerCase!)如果您在基础代码中阅读评论,那么小写的要求似乎更像是一个建议……但是根据我的经验,这似乎更像是一项要求。我有很多好久了!
对于 treeview_b
dragmimetypes
可以是一个空数组,因为我们不会从这里拖动任何东西。handledrag()
方法。dropmimetypes
需要包括我们要落到(即treeview, treeview_b )的树景的MIME我仍然不确定我已经100%了解应该如何实现这一点,但是我可以告诉您上述方法有效。希望它有帮助。
It took me a while to figure out how to get drag & drop to work between two different treeviews. For me, the problem was a combination of:
dragMimeTypes
.treeDataTransfer.set()
.This is probably best described by way of example.
Let's assume we're only going to drag from TreeView_A and we'll only drop onto TreeView_B.
For TreeView_A
dropMimeTypes
can be an empty array as we're not expecting to receive any drops.dragMimeTypes
needs to include the mime type of the treeview that we're going to drop onto (i.e. TreeView_B). A word of warning here, this MUST be in the formatapplication/vnd.code.tree.<treeidlowercase>
. So, for this example it would read something like this:handleDrag()
method needs to set using a mime type of the target treeview (Treeview_B), (remember lowercase!)The lowercase requirement seems more like a suggestion if you read the comments in the underlying code... but no from my experience it seems more like a requirement. Had me stumped for ages!
For TreeView_B
dragMimeTypes
can be an empty array as we won't be dragging anything from here.handleDrag()
method.dropMimeTypes
needs to include the mime type of the treeview that we're going to drop onto (i.e. this treeview, TreeView_B)handleDrop()
method needs to get the correct mime type (you guessed it, Treeview_B in lowercase). In this method, I just log to console.I'm still not sure that I've 100% understood how this is supposed to be implemented, but I can tell you that the above method works. Hope it helps.