在自定义 TreeView 中添加拖放支持 [英] Adding drag and drop support in a custom TreeView

查看:23
本文介绍了在自定义 TreeView 中添加拖放支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过创建 TreeDataProvider 并自定义了图标及其可折叠属性,成功地填充了 TreeView.现在我希望能够将其 ViewItem(s) 拖放到 WebView 上.不幸的是,没有用于拖放的示例.通读 TreeView 源代码,ViewItem(s) 是通过 TreeView.createViewItem()<在 HeightMap.OnInsertItems() 中创建的/code>,来自派生类.

I have successfully populated a TreeView via creating a TreeDataProvider and customized the icons and its collapse-able property. Now I want to be able to drag and drop its ViewItem(s) onto a WebView. There are unfortunately no samples for drag and drop. Reading through the TreeView source, ViewItem(s) are created in HeightMap.OnInsertItems() via the TreeView.createViewItem(), from the derived class.

public TreeView.onInsertItem() 看起来是一个很好的扩展点,扩展 TreeViewonInsertItem() 并捕获它的 ViewItem 参数.不幸的是,最终创建的具体类 ExtHostTreeView 的创建被隐藏在私有方法层中(createExtHostTreeViewer()).

The public TreeView.onInsertItem() would appear to be a great extension point, extending TreeView and onInsertItem() and capturing its ViewItem parameter. This Unfortunately, the creation of the concrete class, ExtHostTreeView, that is ultimately created, is buried in layers of private methods (createExtHostTreeViewer()).

奇怪的是,ViewItem 有一个可拖动的 setter.但是,您将如何获得对 ViewItem 的引用来设置它?如果有办法做到这一点,请给我举个例子.如果没有,我很乐意分叉并实施它.保留现有的 onInsertItem 并可能添加一组处理程序以使用 addOnInsertItemListener() 方法添加到其中?或者也许使用 RxJS?

Strangely, the ViewItem has a setter for draggable. However, how would you ever get a reference to the ViewItem to set it? If there is a way to do this please point me at an example. If there is not, I would be glad to fork and implement it. Leaving the existing onInsertItem and perhaps add an array of handlers to be added to with an addOnInsertItemListener() method? Or perhaps use RxJS?

可以使用的地方太多了.您可以将模板片段拖入文档或代码,将 DSL 规则拖入专家系统,将配置文件值拖入参数或右手值(生成代码以检索值).感谢您的帮助.

There are so many places this could be used. You could drag template fragments into documents or code, DSL rules into a expert system, configuration file values into parameters or right hand values (generating the code to retrieve the value). Thank you for any assistance.

推荐答案

目前似乎不支持在自定义视图中拖放.这里有一个(相当受欢迎的)功能请求:

It seems that drag and drop in custom views is currently not supported. There's a (fairly popular) feature request for it here:

为贡献的树视图添加拖放功能 (#32592)

这篇关于在自定义 TreeView 中添加拖放支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆