Expected Behavior
When right-clicking a CodeArea with context menu (or even without one) that lives in a container that can itself have the keyboard focus, the focus should not be lost by the CodeArea.
When using a (JavaFX built-in) TextArea focus is not lost.
I presume that either the event must be consumed or CodeArea should accept focus upon right-click (it does not at the moment)
Actual Behavior
Focus is lost.
Reproducible Demo
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TitledPane;
import javafx.stage.Stage;
public class ContextMenuFocusBug extends Application {
private CodeArea area;
@Override
public void start(Stage primaryStage) {
area = new CodeArea("Right-click me!\n");
setupContextMenu();
TitledPane container = new TitledPane("Nice", new VirtualizedScrollPane<>(area));
primaryStage.setScene(new Scene(container, 400, 500));
primaryStage.setTitle("Losing focus on right-click");
primaryStage.show();
}
private void setupContextMenu() {
ContextMenu contextMenu = new ContextMenu(
new MenuItem("Test")
);
contextMenu.setStyle("-fx-font-family: 'Droid Sans';"); // hack to get regular styling in context menu
area.setContextMenu(contextMenu);
}
public static void main(String[] args) {
launch(args);
}
}
Environment info:
- RichTextFX Version: 0.10.4
- Operating System: Linux (Fedora 31)
- Java version: 13
Expected Behavior
When right-clicking a CodeArea with context menu (or even without one) that lives in a container that can itself have the keyboard focus, the focus should not be lost by the CodeArea.
When using a (JavaFX built-in) TextArea focus is not lost.
I presume that either the event must be consumed or CodeArea should accept focus upon right-click (it does not at the moment)
Actual Behavior
Focus is lost.
Reproducible Demo
Environment info: