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

Textfield cursor gets offset when cursor is one space left of highlighted text

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Enterprise 64-bit OS

      A DESCRIPTION OF THE PROBLEM :
      Selecting the end of a textfield entry from right to left using the mouse, moving the mouse to the character before the last unhighlighted character then pressing backspace moves the textfield caret to before the last unhighlighted character.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run:

      package javafxbugapplication;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class JavaFXBugApplication extends Application {
         
         @Override
         public void start(Stage primaryStage) {
            TextField txtField = new TextField();
            
            StackPane root = new StackPane();
            root.getChildren().add(txtField);
            
            Scene scene = new Scene(root, 300, 250);
            
            primaryStage.setTitle("Textfield bug");
            primaryStage.setScene(scene);
            primaryStage.show();
         }

         /**
          * @param args the command line arguments
          */
         public static void main(String[] args) {
            launch(args);
         }
         
      }

      or any application with a javafx textfield

      2. Enter "TextField" (no quotes) into the TextField
      3. Highlight "Field" from right to left with the mouse.
      4. Position the mouse cursor on the 'x' in "Text"
      5. Press backspace

      The textfield caret should be between x and t instead of at the end of "Text"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The caret is positioned at the end of "Text"
      ACTUAL -
      The caret is positioned between the 'x' and 't' in "Text"
      The caret is not able to be moved to the right with the right arrow key until the left arrow key is pressed or the caret is moved via mouse click.

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

      ---------- BEGIN SOURCE ----------

      package javafxbugapplication;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class JavaFXBugApplication extends Application {
         
         @Override
         public void start(Stage primaryStage) {
            TextField txtField = new TextField();
            
            StackPane root = new StackPane();
            root.getChildren().add(txtField);
            
            Scene scene = new Scene(root, 300, 250);
            
            primaryStage.setTitle("Textfield bug");
            primaryStage.setScene(scene);
            primaryStage.show();
         }

         /**
          * @param args the command line arguments
          */
         public static void main(String[] args) {
            launch(args);
         }
         
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: