treeviewer does not deselect the tree item

倾然丶 夕夏残阳落幕 提交于 2019-12-11 02:22:10

问题


I wanted to create dynamic tree struture in my application. There my requirement is When the user selects any tree node and click insert the child should be inserted below the selected parent. That is working fine. Now the problem is i am unable to deselect the currently selected tree item in order to change tree item . I clicked the background of the view and tried to insert a new tree item, but still it goes to the previously selected tree node as still it highlight as the selected one. How to solve this issue?


回答1:


If you create a TreeViewer with style SWT.SINGLE then the tree will insist on keeping an item selected unless you explicitly clear the selection.

To clear a selection use:

treeViewer.setSelection(StructuredSelection.EMPTY);

If you use SWT.MULTI as the tree style you can clear the selection with Ctrl+Click



来源:https://stackoverflow.com/questions/19364279/treeviewer-does-not-deselect-the-tree-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!