JDK-8179526 : [linux] Special Characters input via composition do not produce correct KeyEvents on Linux OS
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2017-05-02
  • Updated: 2017-05-10
  • Resolved: 2017-05-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Linux Xavier 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
In RichTextFX (https://github.com/TomasMikula/RichTextFX/issues/280), a custom built text area that does not extend `TextInputControl` cannot input special characters on Linux-based OS. However, special characters can be inputted on Windows or Mac OS

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In the given source code, press the Compose key, the ` key, and the A key. Then click on the TextArea and do the same thing.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Strings outputted from the key events should be the same, indicating that a special character was inputted, not the composition keys that composed it.
ACTUAL -
The code treats each composition key event as a regular keys being pressed. It does not interpret the key presses as a special-character-input event.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class SpecialArea extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Circle rtfxArea = new Circle(50);
        TextArea jfxArea = new TextArea();

        // output the column headers
        outputColumnHeaders();

        // setup listener
        EventHandler<KeyEvent> output = e -> {

            StringBuilder sb = new StringBuilder();
            String type = e.getEventType().toString();
            sb
                    .append(type.substring(4, type.length()))
                    .append("\t").append(e.getCharacter())
                    .append("\t").append(e.getCode())
                    .append("\t").append(e.getText())
                    .append("\t").append(e.isControlDown())
                    .append("\t").append(e.isShiftDown())
                    .append("\t").append(e.isAltDown())
                    .append("\t").append(e.isMetaDown())
                    .append("\t").append(e.isShortcutDown());
            System.out.println(sb.toString());
        };

        // add event filter
        rtfxArea.addEventFilter(KeyEvent.ANY, output);
        jfxArea.addEventFilter(KeyEvent.ANY, output);

        Scene scene = new Scene(new VBox(rtfxArea, jfxArea), 500, 500);
        // re-output headers on S and switch to other area
        scene.addEventHandler(KeyEvent.KEY_RELEASED, e -> {
            if (e.getCode() == KeyCode.S) {
                System.out.println("\n--- Switching to next area ---\n");
                outputColumnHeaders();
                if (rtfxArea.isFocused()) {
                    jfxArea.requestFocus();
                } else {
                    rtfxArea.requestFocus();
                }
                e.consume();
            }
        });
        primaryStage.setScene(scene);
        primaryStage.show();
        rtfxArea.requestFocus();
    }

    private void outputColumnHeaders() {
        StringBuilder sb = new StringBuilder();
        sb.append("Event Type")
                .append("\tChar")
                .append("\tCode")
                .append("\tText")
                .append("\tCTRL")
                .append("\tSHIFT")
                .append("\tALT")
                .append("\tMETA")
                .append("\tSHORT");
        System.out.println(sb.toString());
    }
}
---------- END SOURCE ----------


Comments
As this is platform-specific it is likely a bug in glass, so changing the sub-component to window-toolkit.
02-05-2017

Only getting key Released events for the compose key, not 'Pressed' and 'Typed' events. Issue is reproducible only in Linux. Looks duplicate of JDK-4667953 Ubuntu 14.04.1 LTS (3.13.0-32-generic #57-Ubuntu SMP) ---------- 8b132 : Fail 8u121 : Fail 9ea165 : Fail 9ea167 : Fail
02-05-2017