How to add Content Assist to text field in Wizard using SWT java [closed]

半腔热情 提交于 2020-05-16 03:59:45

问题


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?


回答1:


You can use the JFace ContentProposalAdapter to do this on a Text control.

Use something like:

Text textControl = ....


KeyStroke keyStroke = KeyStroke.getInstance("Ctrl+Space");

new ContentProposalAdapter(textControl, new TextContentAdapter(), provider, keyStroke, null);

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
}


来源:https://stackoverflow.com/questions/42687493/how-to-add-content-assist-to-text-field-in-wizard-using-swt-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!