Page 1 of 1
Auto Complete popup in Applet
Posted: Tue Sep 18, 2012 4:59 pm
by neon096
I've got a field in the XML which has a set list of values that can be used to populate it (i.e true, false). If I pressed Ctrl and Space a popup appears. Is there anyway to get this popup to automatically appear when the caret is within the field?
Re: Auto Complete popup in Applet
Posted: Tue Sep 18, 2012 5:32 pm
by Radu
Hi Neil,
Maybe you could add a caret listener and invoke the action which starts the content completion when the caret moves to a certain context, something like:
Code: Select all
authorComponentProvider.getAuthorAccess().getEditorAccess().addAuthorCaretListener(new AuthorCaretListener() {
public void caretMoved(AuthorCaretEvent caretEvent) {
try {
AuthorNode node = authorComponentProvider.getAuthorAccess().getDocumentController().getNodeAtOffset(caretEvent.getOffset());
if("p".equals(node.getName())) {
//Start CC in it
SwingUtilities.invokeLater(new Runnable() {
public void run() {
authorComponentProvider.getAuthorCommonActions().get("Content_completion/Start_content_completion").actionPerformed(null);
}
});
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
});
Regards,
Radu
Re: Auto Complete popup in Applet
Posted: Wed Sep 19, 2012 11:30 am
by neon096
Thanks Radu,
That works to some degree but you need to make sure everything is in the SwingUtilities.invokeLater otherwise a StackOverflow error will occur.
Is there a way of manipulating the values in the popup as Oxygen is populating the first record with "Enter" and we don't want this?
Re: Auto Complete popup in Applet
Posted: Wed Sep 19, 2012 11:40 am
by Radu
Hi Neil,
Indeed Oxygen adds the ENTER entry if the current element is regarded as space-preserve either by the associated schema or by the CSS.
You have the possibility to remove the ENTER entry from the content completion window but it will be removed in all contexts.
Just edit the document type, in the Author tab select the Content Completion tab and there is a "Remove content completion" items list, add to it <ENTER>.
Regards,
Radu