简体   繁体   中英

How delete an item from SWT TreeViewer?

我正在使用Eclipse Standard Widget Toolkit( SWT ),我有一个包含项目的TreeView对象,并且双击事件( addDoubleClickListener )可以正常工作,但是我不知道如何实现右键单击以删除项目。

  1. To listen to right clicks, use addMenuListener . Eclipse RCP has its own more advanced mechanisms, but this should be enough for your purposes.

  2. In SelectionListener for your MenuItem , remove the item from your model and refresh the viewer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM