如何使用SWT Java将Content Assist添加到向导中的文本字段 [英] How to add Content Assist to text field in Wizard using SWT java
本文介绍了如何使用SWT Java将Content Assist添加到向导中的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用SWT设计了一个带有文本字段的向导页面.我想向文本字段添加内容辅助,即当我按"Ctrl +空格"时,它必须提出数据列表.有任何实现此功能的标准方法吗?
I have designed a wizard page with a text field using SWT. I want to add a content assist to the text field i.e , when i press 'Ctrl+space', it has to propose the list of data. Any standard method to implement this feature?
推荐答案
您可以使用JFace ContentProposalAdapter
在Text
控件上执行此操作.
You can use the JFace ContentProposalAdapter
to do this on a Text
control.
使用类似的东西:
Text textControl = ....
KeyStroke keyStroke = KeyStroke.getInstance("Ctrl+Space");
new ContentProposalAdapter(textControl, new TextContentAdapter(), provider, keyStroke, null);
provider
是实现IContentProposalProvider
的类,它只有一个方法getProposals
:
provider
is a class implementing IContentProposalProvider
this just has one method getProposals
:
@Override
public IContentProposal [] getProposals(String contents, int position)
{
// TODO return array of `ContentProposal` objects appropriate to the contents
}
这篇关于如何使用SWT Java将Content Assist添加到向导中的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文