【发布时间】:2018-02-13 13:59:24
【问题描述】:
我正在为处理我自己的脚本语言的 Eclipse 开发一个编辑器插件。在编辑器中,我有一个悬停显示鼠标光标下元素的简短信息。 现在,我正在尝试在悬停的底部创建一个工具栏,并在那里放置一个按钮,该按钮将在线打开更详细的描述。
我已经根据answer to that question 编写了我的代码。该按钮是可见的,并在单击时起作用。 但是,在我将鼠标移到悬停上后不久,它就会消失。为什么会发生这种情况,我该如何预防?
这是我的代码的相关部分:
@Override
public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(final Shell parent) {
ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
DefaultInformationControl defaultInformationControl = new DefaultInformationControl(parent, tbm);
Action action = new Action() {
@Override
public void run() {
MessageDialog.openInformation(parent, "omg", "It works.");
}
};
action.setText("123 test 321");
Bundle bundle = FrameworkUtil.getBundle(this.getClass());
URL url = FileLocator.find(bundle, new Path("icons/test.gif"), null);
action.setImageDescriptor(ImageDescriptor.createFromURL(url));
tbm.add(action);
tbm.update(true);
return defaultInformationControl;
}
};
}
【问题讨论】:
标签: java eclipse eclipse-plugin editor mousehover