在eclipse树中的树项旁边添加图标按钮 [英] Add icon button beside tree item in eclipse tree

查看:144
本文介绍了在eclipse树中的树项旁边添加图标按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何添加图标,作为树项目右侧的按钮

I wonder how to add an icon that acts as a button in the right side of a tree item

此图标的选择应该与选择树项目本身。

the selection of this icon should have different action than selecting the tree item itself.

我该怎么做?

示例:

认为这是主树

http://www.eclipse.org/articles/Article-TreeViewer/images/main.gif

我想添加图标到一些树项目的标签
的右侧像

and I want to add icons to the right side of some tree items' label like

http://store2.up-00.com/June12/8QI59630.gif

就像当我点击黑星图标时,我做出不同于选择树项目的动作

just as when I click on the black star icon, I make a different action than selecting the tree item

推荐答案

这样的设施不存在于树窗口小部件中,但您可以使用技术cal来自己实现领导所有者绘制你接管树项目的绘画。请参阅OwnerDrawLabelProvider。要响应点击,您需要立即收听鼠标,并在调用您的操作之前检查坐标是否与您的按钮的边界匹配。

Such facility does not exist in the tree widget, but you can implement this yourself using a technique called owner-draw where you take over the painting of tree items. See OwnerDrawLabelProvider. To respond to clicks you will need to listen to mouse down even and check whether the coordinates match the bounds of your button before invoking your action.

这篇关于在eclipse树中的树项旁边添加图标按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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