Auto Complete popup in Applet

Oxygen general issues.
neon096
Posts: 45
Joined: Wed May 23, 2012 11:20 am

Auto Complete popup in Applet

Post 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?
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Auto Complete popup in Applet

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
neon096
Posts: 45
Joined: Wed May 23, 2012 11:20 am

Re: Auto Complete popup in Applet

Post 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?
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Auto Complete popup in Applet

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply