bobbylight / AutoComplete

A code completion library for Swing text components, with special support for RSyntaxTextArea.
BSD 3-Clause "New" or "Revised" License
166 stars 55 forks source link

JavaFX - AutoComplete pop up showing, but buggy #82

Open pshdev0 opened 3 years ago

pshdev0 commented 3 years ago

Running on Mac, I got the RSyntaxTextArea working as a standalone Swing application and as a separate application in a SwingNode in JavaFX, but when I press ctrl+SPACE in either version no window pop up is shown. My JavaFX code is below.

However, if I press SPACE then ctrl in that order, the pop up shows in an on-off flashing fashion and when I release SPACE, depending on whether the pop is showing or not, it stays on the screen !

Is this a bug ? Why is is not showing normally with just a ctrl+SPACE? Thanks.

final SwingNode swing = new SwingNode();
pluginsAnchor.getChildren().add(swing);

JPanel cp = new JPanel(new BorderLayout());
textArea = new RSyntaxTextArea(40, 100);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
RTextScrollPane sp2 = new RTextScrollPane(textArea);
cp.add(sp2);

CompletionProvider provider = createCompletionProvider();
AutoCompletion ac = new AutoCompletion(provider);
ac.install(textArea);

swing.setContent(cp);

Turns out if I add:

ac.setTriggerKey(KeyStroke.getKeyStroke('\t'));

the pop up appears, but it also tabs in the editor. There seems to be a real problem with setting the combination of CONTROL + SPACE. It doesn't work.

I managed to get it working with a different key combo using:

ac.setTriggerKey(KeyStroke.getKeyStroke("ctrl released ENTER"));   // why won't "ctrl pressed SPACE" work ?
bobbylight commented 2 years ago

Can you provide an SSCCE demonstrating the behavior (e.g. a standalone class with a main method)? I'm not a javafx guy, so if there's extra stuff you need to do to build with JavaFX in later Java versions (IIRC there is, it was removed from the core JRE or some such?) let me know that as well.

I remember having some issues with standalone RSTA in JavaFX back when it was a newer technology. I think there was problems around focus and z-order when embedding it into a JavaFX app. Maybe this is a similar issue. We do a lot of fun stuff with intercepting key events so maybe there's a bug in there we can identify and address.