在eclipse树中的树项旁边添加图标按钮 [英] Add icon button beside tree item in eclipse tree
问题描述
我想知道如何添加图标,作为树项目右侧的按钮
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屋!