SWT:防止树通过双击扩展? [英] SWT: prevent Tree from expanding by doubleclick?

查看:30
本文介绍了SWT:防止树通过双击扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 SWT 树有疑问.我的情况是这样的:我有一个 SWT 树,其中包含许多 TreeItem(日志条目),其中也包含 TreeItem.这些日志条目有很长的消息,根本无法在 TreeColumns 中显示.所以我的想法是:向树添加一个监听器,这会通过 DoubleClick 打开一个新的对话框,其中显示条目的详细信息.到现在为止还挺好.如果我双击一个项目,它就可以工作.但是:如果我双击父项,它将展开(这很好),但是我的双击侦听器也处于活动状态,对话框将打开.这不是我想要的.

I have a problem with SWT Tree. My situation is like this: I have a SWT Tree, which contains many TreeItems (Log entries), which contain TreeItems too. Those log entries have really long messages, which could not be shown in the TreeColumns at all. So my idea was: adding a Listener to the tree, which opens a new Dialog by DoubleClick, which shows the entries' details. So far so good. If I do a double click on a item, it works. BUT: If I do a double click on a parent Item, it will expand (and thats good), but my double click Listener is active then as well and the Dialog will open. That's not, what I want.

所以,这个问题有两种解决方案:1) 防止 Tree 自动双击展开/折叠并自行实现该方法或2) 认识到该项目已展开并且必须中止该事件.

So, there are two solutions to the problem: 1) prevent the Tree from expanding/collapsing by double click automatically and implement the method by myself or 2) recognize, that the item was expanded and the event has to be aborted.

我真的不知道如何做 1 或 2.你们知道吗?

I do not really know how to do 1 or 2. Do u guys know that?

提前致谢.

推荐答案

如果你正在使用 TreeViewer,你可以使用 IOpenListener

If you are using TreeViewer, you could make use of IOpenListener

treeViewer.addOpenListener(new IOpenListener() {

      @Override
      public void open(OpenEvent event) {
}
}

这篇关于SWT:防止树通过双击扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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