Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248914

Javafx TextField positions the cursor incorrectly after pressing DEL key

XMLWordPrintable

    • b21
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      I have a Windows 10 machine.
      I could reproduce it in Java 8, Java 11, Java 14, and Java 15

      A DESCRIPTION OF THE PROBLEM :
      If use your mouse to click on the TextField to position the cursor right before a character, then if you press DEL key to delete the said character, you will notice that the cursor will be shifted one character to the left instead staying put.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the following sample code.
      2. Use your mouse to click on the exact spot between 'a' and 'b' characters (edit 2023/11/30: more correctly, trailing edge of 'a', the leading edge of 'b' seems to work). This will put the cursor right after 'a'.
      3. Press the DELETE key in your keyboard.

      Note: You have to use your mouse to click on 'b' to move the cursor there. If you use your keyboard arrow keys to move the cursor there then this bug won't happen.

      Also make sure to press DELETE key, not the BACKSPACE key.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Character `b` should be deleted and the cursor should not move (remain at AFTER `a` character).
      ACTUAL -
      Character `b` is deleted but the cursor moves to left. It will end up at BEFOR the `a` character.

      ---------- BEGIN SOURCE ----------
      TextField text1 = new TextField("abc");
      TextField text2 = new TextField("abc");
      HBox root = new HBox(text1, text2);
      Scene scene = new Scene(root, 800, 600);
      stage.setScene(scene);
      stage.show();
      ---------- END SOURCE ----------

      FREQUENCY : always


      edit 2023/08/22: also reproducible on macOS 13.3.1a
      edit 2023/11/30: steps to reproduce: it's important to click on the trailing edge of 'a' char. clicking on the leading edge of 'b' char appear to work fine.

        1. TextFieldTest.java
          0.9 kB
          Praveen Narayanaswamy

            kpk Karthik P K
            webbuggrp Webbug Group
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: