I have attached a content assist to a text box by using the below code. The content assist is working fine. But, once I press the 'Ctrl+space', then, All the proposals are displayed in a newly created shell. Then, I try to type some more characters, but, I'm unable to type, as the new shell has the focus, not the text box.
Is there a way to minic, how the JDT editor does? Even after pressing the Ctrl+space and content proposals are displayed, we are able to type in the editor and the proposals are narrowed down based on the new characters.
private void attachContentAssist(final Text propertyText) {
ContentProposalAdapter contentProposalAdapter = new ContentProposalAdapter(propertyText, new TextContentAdapter(),
this.proposalProvider, KeyStroke.getInstance("Ctrl+Space"), null);
contentProposalAdapter.setLabelProvider(new ContentProposalLabelProvider());
contentProposalAdapter.setPropagateKeys(false);
contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
}
The line:
contentProposalAdapter.setPropagateKeys(false);
is stopping keys received while to pop-up is open being forwarded to the Text control, this is what is stopping the typing working.
Either specify true
or remove the line as true
is the default.